three-base 2.0.129 → 2.0.134
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/ApngTexture.d.ts +13 -13
- package/ApngTexture.js +61 -61
- package/ApngTextureManage.d.ts +18 -18
- package/ApngTextureManage.js +87 -87
- package/DirectionalLight.d.ts +6 -0
- package/DirectionalLight.js +68 -0
- package/EventMesh.d.ts +18 -18
- package/EventMesh.js +59 -59
- package/ExtrudeMesh.d.ts +112 -112
- package/ExtrudeMesh.js +366 -366
- package/FPScontrol.d.ts +71 -50
- package/FPScontrol.js +505 -232
- package/Fire/Fire.d.ts +28 -28
- package/Fire/Fire.js +79 -79
- package/Fire/FireGromtry.d.ts +9 -9
- package/Fire/FireGromtry.js +40 -40
- package/Fire/FireMaterial.d.ts +28 -28
- package/Fire/FireMaterial.js +32 -32
- package/Fire/index.d.ts +1 -1
- package/Fire/index.js +1 -1
- package/Grass/Grass.d.ts +8 -8
- package/Grass/Grass.js +38 -38
- package/Grass/index.d.ts +1 -1
- package/Grass/index.js +1 -1
- package/Ground1/Ground1.d.ts +11 -11
- package/Ground1/Ground1.js +54 -54
- package/Ground1/index.d.ts +1 -1
- package/Ground1/index.js +1 -1
- package/InstancedMeshBase.d.ts +39 -39
- package/InstancedMeshBase.js +293 -293
- package/KeyFrameAnimation.d.ts +25 -25
- package/KeyFrameAnimation.js +78 -78
- package/MeshBase.d.ts +35 -35
- package/MeshBase.js +223 -223
- package/Mirror.d.ts +25 -25
- package/Mirror.js +139 -139
- package/PipeMesh/PathGeometry.d.ts +44 -44
- package/PipeMesh/PathGeometry.js +300 -300
- package/PipeMesh/PathPoint.d.ts +17 -17
- package/PipeMesh/PathPoint.js +31 -31
- package/PipeMesh/PathPointList.d.ts +31 -31
- package/PipeMesh/PathPointList.js +208 -208
- package/PipeMesh/PathTubeGeometry.d.ts +25 -25
- package/PipeMesh/PathTubeGeometry.js +130 -130
- package/PipeMesh/PipeMesh.d.ts +25 -25
- package/PipeMesh/PipeMesh.js +63 -63
- package/PipeMesh/index.d.ts +1 -1
- package/PipeMesh/index.js +1 -1
- package/PlaneModal1/PlaneModal1.d.ts +31 -31
- package/PlaneModal1/PlaneModal1.js +105 -105
- package/PlaneModal1/index.d.ts +1 -1
- package/PlaneModal1/index.js +1 -1
- package/PlaneText.d.ts +39 -39
- package/PlaneText.js +30 -30
- package/PlaneWithHtml.d.ts +11 -11
- package/PlaneWithHtml.js +63 -68
- package/PointLight/PointLight.d.ts +14 -13
- package/PointLight/PointLight.js +70 -64
- package/PointLight/index.d.ts +1 -1
- package/PointLight/index.js +1 -1
- package/Sky/Sky.d.ts +9 -9
- package/Sky/Sky.js +22 -22
- package/Sky/index.d.ts +1 -1
- package/Sky/index.js +1 -1
- package/SpotLight.d.ts +6 -0
- package/SpotLight.js +72 -0
- package/SpriteModal1/SpriteModal1.d.ts +30 -30
- package/SpriteModal1/SpriteModal1.js +110 -110
- package/SpriteModal1/index.d.ts +1 -1
- package/SpriteModal1/index.js +1 -1
- package/SpriteText.d.ts +45 -45
- package/SpriteText.js +163 -163
- package/SpriteText2.d.ts +47 -47
- package/SpriteText2.js +198 -198
- package/SpriteWithHtml.d.ts +7 -7
- package/SpriteWithHtml.js +44 -49
- package/Text3D/Text3D.d.ts +20 -20
- package/Text3D/Text3D.js +62 -62
- package/Text3D/fontController.d.ts +59 -59
- package/Text3D/fontController.js +199 -199
- package/Text3D/index.d.ts +1 -1
- package/Text3D/index.js +1 -1
- package/ThreeBase.d.ts +97 -81
- package/ThreeBase.js +613 -559
- package/ThreeMouse.d.ts +40 -40
- package/ThreeMouse.js +407 -409
- package/Transition.d.ts +40 -40
- package/Transition.js +210 -207
- package/Water/Water.d.ts +5 -0
- package/Water/Water.js +26 -0
- package/Water/waternormals.jpg +0 -0
- package/declare.d.ts +167 -0
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/keyContorls.d.ts +25 -25
- package/keyContorls.js +98 -98
- package/package.json +1 -1
- package/pass/bloom_pass.d.ts +2 -2
- package/pass/bloom_pass.js +99 -99
- package/pass/cover_pass.d.ts +2 -2
- package/pass/cover_pass.js +95 -95
- package/pass/frosted_glass_pass.d.ts +2 -0
- package/pass/frosted_glass_pass.js +275 -0
- package/pass/fsQuad.d.ts +9 -9
- package/pass/fsQuad.js +28 -28
- package/pass/glow_pass.d.ts +2 -2
- package/pass/glow_pass.js +310 -254
- package/pass/ssao_pass.d.ts +11 -0
- package/pass/ssao_pass.js +294 -0
- package/pass/stroke_pass.d.ts +2 -2
- package/pass/stroke_pass.js +199 -199
- package/shaders/FXAAShaderMaterial.d.ts +3 -3
- package/shaders/FXAAShaderMaterial.js +21 -21
- package/shaders/baseTextureToRenderShader.d.ts +2 -2
- package/shaders/baseTextureToRenderShader.js +14 -14
- package/shaders/copyShader.d.ts +3 -3
- package/shaders/copyShader.js +14 -14
- package/shaders.d.ts +5 -5
- package/shaders.js +42 -42
- package/threeLoader.d.ts +34 -34
- package/threeLoader.js +527 -527
- package/threeUtils.d.ts +52 -52
- package/threeUtils.js +330 -330
package/ApngTexture.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { APNG } from "apng-js";
|
|
2
|
-
import Player from "apng-js/types/library/player";
|
|
3
|
-
import { CanvasTexture } from "three";
|
|
4
|
-
export default class ApngTexture extends CanvasTexture {
|
|
5
|
-
constructor(url: string);
|
|
6
|
-
static TimeTemp: number;
|
|
7
|
-
preUpdate: number;
|
|
8
|
-
player?: Player;
|
|
9
|
-
apng?: APNG;
|
|
10
|
-
onUpdate: () => void;
|
|
11
|
-
getUuid(): number | "";
|
|
12
|
-
loadApng(url: string): Promise<void>;
|
|
13
|
-
}
|
|
1
|
+
import { APNG } from "apng-js";
|
|
2
|
+
import Player from "apng-js/types/library/player";
|
|
3
|
+
import { CanvasTexture } from "three";
|
|
4
|
+
export default class ApngTexture extends CanvasTexture {
|
|
5
|
+
constructor(url: string);
|
|
6
|
+
static TimeTemp: number;
|
|
7
|
+
preUpdate: number;
|
|
8
|
+
player?: Player;
|
|
9
|
+
apng?: APNG;
|
|
10
|
+
onUpdate: () => void;
|
|
11
|
+
getUuid(): number | "";
|
|
12
|
+
loadApng(url: string): Promise<void>;
|
|
13
|
+
}
|
package/ApngTexture.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import parseAPNG from "apng-js";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import { CanvasTexture } from "three";
|
|
4
|
-
import threeUtils from "./threeUtils";
|
|
5
|
-
export default class ApngTexture extends CanvasTexture {
|
|
6
|
-
constructor(url) {
|
|
7
|
-
super(document.createElement("canvas"));
|
|
8
|
-
this.loadApng(url);
|
|
9
|
-
}
|
|
10
|
-
// 获取时间戳
|
|
11
|
-
static TimeTemp = performance.now();
|
|
12
|
-
// 上一次更新时间
|
|
13
|
-
preUpdate = 0;
|
|
14
|
-
player;
|
|
15
|
-
// apng 对象
|
|
16
|
-
apng;
|
|
17
|
-
// 更新纹理
|
|
18
|
-
onUpdate = () => {
|
|
19
|
-
if (this.preUpdate === ApngTexture.TimeTemp) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
this.preUpdate = ApngTexture.TimeTemp;
|
|
23
|
-
if (this.player) {
|
|
24
|
-
this.player.renderNextFrame();
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
// 获取当前帧id
|
|
28
|
-
getUuid() {
|
|
29
|
-
if (this.apng) {
|
|
30
|
-
let currentTime = ApngTexture.TimeTemp % this.apng.playTime;
|
|
31
|
-
let i = 0;
|
|
32
|
-
while (this.apng.frames[i] && currentTime > this.apng.frames[i].delay) {
|
|
33
|
-
currentTime -= this.apng.frames[i].delay;
|
|
34
|
-
i++;
|
|
35
|
-
}
|
|
36
|
-
return this.apng.frames[i].delay;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return "";
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// 加载apng图片
|
|
43
|
-
async loadApng(url) {
|
|
44
|
-
const res = await axios.get(url, { method: "post", responseType: "blob" });
|
|
45
|
-
const blob = new Blob([res.data]);
|
|
46
|
-
const reader = new FileReader();
|
|
47
|
-
await new Promise((resolve) => {
|
|
48
|
-
reader.onload = () => resolve();
|
|
49
|
-
reader.readAsArrayBuffer(blob);
|
|
50
|
-
});
|
|
51
|
-
const apng = parseAPNG(reader.result);
|
|
52
|
-
this.dispose();
|
|
53
|
-
this.image.width = apng.width;
|
|
54
|
-
this.image.height = apng.height;
|
|
55
|
-
this.player = await apng.getPlayer(this.image.getContext("2d"));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// 定时更新时间戳
|
|
59
|
-
threeUtils.addEventListener("requestAnimationFrame", (e) => {
|
|
60
|
-
ApngTexture.TimeTemp = e.timeTemp;
|
|
61
|
-
});
|
|
1
|
+
import parseAPNG from "apng-js";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import { CanvasTexture } from "three";
|
|
4
|
+
import threeUtils from "./threeUtils";
|
|
5
|
+
export default class ApngTexture extends CanvasTexture {
|
|
6
|
+
constructor(url) {
|
|
7
|
+
super(document.createElement("canvas"));
|
|
8
|
+
this.loadApng(url);
|
|
9
|
+
}
|
|
10
|
+
// 获取时间戳
|
|
11
|
+
static TimeTemp = performance.now();
|
|
12
|
+
// 上一次更新时间
|
|
13
|
+
preUpdate = 0;
|
|
14
|
+
player;
|
|
15
|
+
// apng 对象
|
|
16
|
+
apng;
|
|
17
|
+
// 更新纹理
|
|
18
|
+
onUpdate = () => {
|
|
19
|
+
if (this.preUpdate === ApngTexture.TimeTemp) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
this.preUpdate = ApngTexture.TimeTemp;
|
|
23
|
+
if (this.player) {
|
|
24
|
+
this.player.renderNextFrame();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
// 获取当前帧id
|
|
28
|
+
getUuid() {
|
|
29
|
+
if (this.apng) {
|
|
30
|
+
let currentTime = ApngTexture.TimeTemp % this.apng.playTime;
|
|
31
|
+
let i = 0;
|
|
32
|
+
while (this.apng.frames[i] && currentTime > this.apng.frames[i].delay) {
|
|
33
|
+
currentTime -= this.apng.frames[i].delay;
|
|
34
|
+
i++;
|
|
35
|
+
}
|
|
36
|
+
return this.apng.frames[i].delay;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// 加载apng图片
|
|
43
|
+
async loadApng(url) {
|
|
44
|
+
const res = await axios.get(url, { method: "post", responseType: "blob" });
|
|
45
|
+
const blob = new Blob([res.data]);
|
|
46
|
+
const reader = new FileReader();
|
|
47
|
+
await new Promise((resolve) => {
|
|
48
|
+
reader.onload = () => resolve();
|
|
49
|
+
reader.readAsArrayBuffer(blob);
|
|
50
|
+
});
|
|
51
|
+
const apng = parseAPNG(reader.result);
|
|
52
|
+
this.dispose();
|
|
53
|
+
this.image.width = apng.width;
|
|
54
|
+
this.image.height = apng.height;
|
|
55
|
+
this.player = await apng.getPlayer(this.image.getContext("2d"));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// 定时更新时间戳
|
|
59
|
+
threeUtils.addEventListener("requestAnimationFrame", (e) => {
|
|
60
|
+
ApngTexture.TimeTemp = e.timeTemp;
|
|
61
|
+
});
|
package/ApngTextureManage.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Texture, TextureLoader } from "three";
|
|
2
|
-
/**
|
|
3
|
-
* apng 纹理管理对象
|
|
4
|
-
*/
|
|
5
|
-
declare class apngTextureManage {
|
|
6
|
-
constructor();
|
|
7
|
-
static TextureLoader: TextureLoader;
|
|
8
|
-
static isInit: boolean;
|
|
9
|
-
static TimeTemp: number;
|
|
10
|
-
playTimes: Map<any, any>;
|
|
11
|
-
anpgTextList: {
|
|
12
|
-
[key: string]: Texture[];
|
|
13
|
-
};
|
|
14
|
-
getTexture(path: string): Texture;
|
|
15
|
-
loadApng(url: string): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
declare const ApngTextureManage: apngTextureManage;
|
|
18
|
-
export default ApngTextureManage;
|
|
1
|
+
import { Texture, TextureLoader } from "three";
|
|
2
|
+
/**
|
|
3
|
+
* apng 纹理管理对象
|
|
4
|
+
*/
|
|
5
|
+
declare class apngTextureManage {
|
|
6
|
+
constructor();
|
|
7
|
+
static TextureLoader: TextureLoader;
|
|
8
|
+
static isInit: boolean;
|
|
9
|
+
static TimeTemp: number;
|
|
10
|
+
playTimes: Map<any, any>;
|
|
11
|
+
anpgTextList: {
|
|
12
|
+
[key: string]: Texture[];
|
|
13
|
+
};
|
|
14
|
+
getTexture(path: string): Texture;
|
|
15
|
+
loadApng(url: string): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
declare const ApngTextureManage: apngTextureManage;
|
|
18
|
+
export default ApngTextureManage;
|
package/ApngTextureManage.js
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import parseAPNG from "apng-js";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import { isEmpty } from "lodash";
|
|
4
|
-
import { MirroredRepeatWrapping, TextureLoader } from "three";
|
|
5
|
-
import threeUtils from "./threeUtils";
|
|
6
|
-
/**
|
|
7
|
-
* apng 纹理管理对象
|
|
8
|
-
*/
|
|
9
|
-
class apngTextureManage {
|
|
10
|
-
constructor() {
|
|
11
|
-
// 初始化定时更新时间戳
|
|
12
|
-
if (apngTextureManage.isInit) {
|
|
13
|
-
apngTextureManage.isInit = false;
|
|
14
|
-
threeUtils.addEventListener("requestAnimationFrame5000", (e) => {
|
|
15
|
-
apngTextureManage.TimeTemp = e.timeTemp;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
static TextureLoader = new TextureLoader();
|
|
20
|
-
static isInit = true;
|
|
21
|
-
// 获取时间戳
|
|
22
|
-
static TimeTemp = performance.now();
|
|
23
|
-
// 每个动态纹理的播放总时长
|
|
24
|
-
playTimes = new Map();
|
|
25
|
-
// 保存所有的动态纹理
|
|
26
|
-
anpgTextList = {};
|
|
27
|
-
// 获取动态纹理 需要每帧都获取一下
|
|
28
|
-
getTexture(path) {
|
|
29
|
-
// 如果 没有这个纹理就返回空同时开始加载这个纹理
|
|
30
|
-
if (!this.anpgTextList[path]) {
|
|
31
|
-
this.anpgTextList[path] = [];
|
|
32
|
-
this.loadApng(path);
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
else if (isEmpty(this.anpgTextList[path])) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const playTime = this.playTimes.get(path);
|
|
40
|
-
let currentTime = apngTextureManage.TimeTemp % playTime;
|
|
41
|
-
let i = 0;
|
|
42
|
-
while (this.anpgTextList[path][i] && currentTime > Number(this.anpgTextList[path][i].name)) {
|
|
43
|
-
currentTime -= Number(this.anpgTextList[path][i].name);
|
|
44
|
-
i++;
|
|
45
|
-
}
|
|
46
|
-
this.anpgTextList[path][i].needsUpdate = true;
|
|
47
|
-
return this.anpgTextList[path][i];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// 加载apng图片
|
|
51
|
-
async loadApng(url) {
|
|
52
|
-
const res = await axios.get(url, { method: "post", responseType: "blob" });
|
|
53
|
-
const blob = new Blob([res.data]);
|
|
54
|
-
const reader = new FileReader();
|
|
55
|
-
await new Promise((resolve) => {
|
|
56
|
-
reader.onload = () => resolve();
|
|
57
|
-
reader.readAsArrayBuffer(blob);
|
|
58
|
-
});
|
|
59
|
-
const apng = parseAPNG(reader.result);
|
|
60
|
-
// 存储播放时长
|
|
61
|
-
this.playTimes.set(url, apng.playTime);
|
|
62
|
-
// for (let i = 0; i < apng.frames.length; i++) {
|
|
63
|
-
// const frame = apng.frames[i];
|
|
64
|
-
// frame.createImage();
|
|
65
|
-
// await new Promise(resolve => frame.imageElement!.onload = resolve);
|
|
66
|
-
// }
|
|
67
|
-
for (let i = 0; i < apng.frames.length; i++) {
|
|
68
|
-
const frame = apng.frames[i];
|
|
69
|
-
var blobUrl = URL.createObjectURL(frame.imageData);
|
|
70
|
-
const texture = apngTextureManage.TextureLoader.load(blobUrl);
|
|
71
|
-
texture.anisotropy = 16;
|
|
72
|
-
texture.wrapS = texture.wrapT = MirroredRepeatWrapping;
|
|
73
|
-
// export const RepeatWrapping: Wrapping;
|
|
74
|
-
// export const ClampToEdgeWrapping: Wrapping;
|
|
75
|
-
// export const MirroredRepeatWrapping: Wrapping;
|
|
76
|
-
// magFilter: TextureFilter;
|
|
77
|
-
// minFilter: TextureFilter;
|
|
78
|
-
texture.name = String(frame.delay);
|
|
79
|
-
texture.center.set(0.5, 0.5);
|
|
80
|
-
texture.repeat.set(apng.width / frame.width, apng.height / frame.height);
|
|
81
|
-
// texture.needsUpdate = true;
|
|
82
|
-
this.anpgTextList[url].push(texture);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const ApngTextureManage = new apngTextureManage();
|
|
87
|
-
export default ApngTextureManage;
|
|
1
|
+
import parseAPNG from "apng-js";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import { isEmpty } from "lodash";
|
|
4
|
+
import { MirroredRepeatWrapping, TextureLoader } from "three";
|
|
5
|
+
import threeUtils from "./threeUtils";
|
|
6
|
+
/**
|
|
7
|
+
* apng 纹理管理对象
|
|
8
|
+
*/
|
|
9
|
+
class apngTextureManage {
|
|
10
|
+
constructor() {
|
|
11
|
+
// 初始化定时更新时间戳
|
|
12
|
+
if (apngTextureManage.isInit) {
|
|
13
|
+
apngTextureManage.isInit = false;
|
|
14
|
+
threeUtils.addEventListener("requestAnimationFrame5000", (e) => {
|
|
15
|
+
apngTextureManage.TimeTemp = e.timeTemp;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
static TextureLoader = new TextureLoader();
|
|
20
|
+
static isInit = true;
|
|
21
|
+
// 获取时间戳
|
|
22
|
+
static TimeTemp = performance.now();
|
|
23
|
+
// 每个动态纹理的播放总时长
|
|
24
|
+
playTimes = new Map();
|
|
25
|
+
// 保存所有的动态纹理
|
|
26
|
+
anpgTextList = {};
|
|
27
|
+
// 获取动态纹理 需要每帧都获取一下
|
|
28
|
+
getTexture(path) {
|
|
29
|
+
// 如果 没有这个纹理就返回空同时开始加载这个纹理
|
|
30
|
+
if (!this.anpgTextList[path]) {
|
|
31
|
+
this.anpgTextList[path] = [];
|
|
32
|
+
this.loadApng(path);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
else if (isEmpty(this.anpgTextList[path])) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const playTime = this.playTimes.get(path);
|
|
40
|
+
let currentTime = apngTextureManage.TimeTemp % playTime;
|
|
41
|
+
let i = 0;
|
|
42
|
+
while (this.anpgTextList[path][i] && currentTime > Number(this.anpgTextList[path][i].name)) {
|
|
43
|
+
currentTime -= Number(this.anpgTextList[path][i].name);
|
|
44
|
+
i++;
|
|
45
|
+
}
|
|
46
|
+
this.anpgTextList[path][i].needsUpdate = true;
|
|
47
|
+
return this.anpgTextList[path][i];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// 加载apng图片
|
|
51
|
+
async loadApng(url) {
|
|
52
|
+
const res = await axios.get(url, { method: "post", responseType: "blob" });
|
|
53
|
+
const blob = new Blob([res.data]);
|
|
54
|
+
const reader = new FileReader();
|
|
55
|
+
await new Promise((resolve) => {
|
|
56
|
+
reader.onload = () => resolve();
|
|
57
|
+
reader.readAsArrayBuffer(blob);
|
|
58
|
+
});
|
|
59
|
+
const apng = parseAPNG(reader.result);
|
|
60
|
+
// 存储播放时长
|
|
61
|
+
this.playTimes.set(url, apng.playTime);
|
|
62
|
+
// for (let i = 0; i < apng.frames.length; i++) {
|
|
63
|
+
// const frame = apng.frames[i];
|
|
64
|
+
// frame.createImage();
|
|
65
|
+
// await new Promise(resolve => frame.imageElement!.onload = resolve);
|
|
66
|
+
// }
|
|
67
|
+
for (let i = 0; i < apng.frames.length; i++) {
|
|
68
|
+
const frame = apng.frames[i];
|
|
69
|
+
var blobUrl = URL.createObjectURL(frame.imageData);
|
|
70
|
+
const texture = apngTextureManage.TextureLoader.load(blobUrl);
|
|
71
|
+
texture.anisotropy = 16;
|
|
72
|
+
texture.wrapS = texture.wrapT = MirroredRepeatWrapping;
|
|
73
|
+
// export const RepeatWrapping: Wrapping;
|
|
74
|
+
// export const ClampToEdgeWrapping: Wrapping;
|
|
75
|
+
// export const MirroredRepeatWrapping: Wrapping;
|
|
76
|
+
// magFilter: TextureFilter;
|
|
77
|
+
// minFilter: TextureFilter;
|
|
78
|
+
texture.name = String(frame.delay);
|
|
79
|
+
texture.center.set(0.5, 0.5);
|
|
80
|
+
texture.repeat.set(apng.width / frame.width, apng.height / frame.height);
|
|
81
|
+
// texture.needsUpdate = true;
|
|
82
|
+
this.anpgTextList[url].push(texture);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const ApngTextureManage = new apngTextureManage();
|
|
87
|
+
export default ApngTextureManage;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: xiaosihan
|
|
3
|
+
* @Date: 2024-06-08 14:00:00
|
|
4
|
+
* @Last Modified by: xiaosihan
|
|
5
|
+
* @Last Modified time: 2024-06-08 14:00:00
|
|
6
|
+
*/
|
|
7
|
+
import { DirectionalLight as THREEDirectionalLight, Group, BufferGeometry, BufferAttribute, LineBasicMaterial, LineSegments, ConeGeometry, MeshBasicMaterial, Mesh, } from "three";
|
|
8
|
+
import threeUtils from "./threeUtils";
|
|
9
|
+
import SpriteText from "./SpriteText";
|
|
10
|
+
/** 平行光(dev 模式显示方向箭头 + 阴影范围线框) */
|
|
11
|
+
export default class DirectionalLight extends THREEDirectionalLight {
|
|
12
|
+
constructor(color = "#fff", intensity = 1) {
|
|
13
|
+
super(color, intensity);
|
|
14
|
+
}
|
|
15
|
+
/* ============ dev 模式可视化 ============ */
|
|
16
|
+
_devGroup = threeUtils.isDev && (() => {
|
|
17
|
+
const group = new Group();
|
|
18
|
+
// ——— 方向箭头 ———
|
|
19
|
+
const arrVerts = new Float32Array([
|
|
20
|
+
0, 0, 0.3, 0, 0, -2,
|
|
21
|
+
0, 0, -2, -0.2, 0, -1.6,
|
|
22
|
+
0, 0, -2, 0.2, 0, -1.6,
|
|
23
|
+
]);
|
|
24
|
+
const arrGeo = new BufferGeometry();
|
|
25
|
+
arrGeo.setAttribute("position", new BufferAttribute(arrVerts, 3));
|
|
26
|
+
const arrLine = new LineSegments(arrGeo, new LineBasicMaterial({
|
|
27
|
+
color: this.color, depthTest: false,
|
|
28
|
+
}));
|
|
29
|
+
group.add(arrLine);
|
|
30
|
+
// ——— 阴影范围线框 ———
|
|
31
|
+
const half = 2;
|
|
32
|
+
const rectVerts = new Float32Array([
|
|
33
|
+
-half, -half, -2.2, half, -half, -2.2,
|
|
34
|
+
half, -half, -2.2, half, half, -2.2,
|
|
35
|
+
half, half, -2.2, -half, half, -2.2,
|
|
36
|
+
-half, half, -2.2, -half, -half, -2.2,
|
|
37
|
+
]);
|
|
38
|
+
const rectGeo = new BufferGeometry();
|
|
39
|
+
rectGeo.setAttribute("position", new BufferAttribute(rectVerts, 3));
|
|
40
|
+
const rectLine = new LineSegments(rectGeo, new LineBasicMaterial({
|
|
41
|
+
color: this.color, depthTest: false,
|
|
42
|
+
}));
|
|
43
|
+
group.add(rectLine);
|
|
44
|
+
// ——— 小锥体箭头头部 ———
|
|
45
|
+
const cone = new Mesh(new ConeGeometry(0.15, 0.35, 6), new MeshBasicMaterial({ color: this.color, depthTest: false }));
|
|
46
|
+
cone.position.set(0, 0, -2);
|
|
47
|
+
cone.rotation.x = Math.PI / 2;
|
|
48
|
+
group.add(cone);
|
|
49
|
+
// ——— 标签 ———
|
|
50
|
+
const label = new SpriteText("平行光\n\n");
|
|
51
|
+
label.renderOrder = Infinity;
|
|
52
|
+
label.padding = 4;
|
|
53
|
+
label.strokeColor = "#333";
|
|
54
|
+
label.strokeWidth = 2;
|
|
55
|
+
label.position.set(0, -0.5, 0);
|
|
56
|
+
label.visible = false;
|
|
57
|
+
label.material.color = this.color;
|
|
58
|
+
label.material.sizeAttenuation = false;
|
|
59
|
+
label.scale.multiplyScalar(0.003);
|
|
60
|
+
group.add(label);
|
|
61
|
+
// ——— 交互 ———
|
|
62
|
+
group.userData = { cursor: "pointer" };
|
|
63
|
+
group.addEventListener("mouseenter", () => { label.visible = true; });
|
|
64
|
+
group.addEventListener("mouseleave", () => { label.visible = false; });
|
|
65
|
+
this.add(group);
|
|
66
|
+
return group;
|
|
67
|
+
})();
|
|
68
|
+
}
|
package/EventMesh.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { BoxGeometry, BufferGeometry, CylinderGeometry, Material, Mesh, MeshNormalMaterial } from "three";
|
|
2
|
-
export declare enum CollisionShaere {
|
|
3
|
-
cube = "cube"
|
|
4
|
-
cylinder = "cylinder"
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* 碰撞检测用的模型
|
|
8
|
-
*/
|
|
9
|
-
export default class EventMesh extends Mesh<BufferGeometry, Material> {
|
|
10
|
-
constructor(type?: CollisionShaere);
|
|
11
|
-
static type: typeof CollisionShaere;
|
|
12
|
-
static material: MeshNormalMaterial;
|
|
13
|
-
renderOrder: number;
|
|
14
|
-
static cubeGeo: BoxGeometry;
|
|
15
|
-
static cylinderGeo: CylinderGeometry;
|
|
16
|
-
isEventMesh: boolean;
|
|
17
|
-
setType(type: CollisionShaere): void;
|
|
18
|
-
}
|
|
1
|
+
import { BoxGeometry, BufferGeometry, CylinderGeometry, Material, Mesh, MeshNormalMaterial } from "three";
|
|
2
|
+
export declare enum CollisionShaere {
|
|
3
|
+
cube = "cube",// 正方体
|
|
4
|
+
cylinder = "cylinder"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 碰撞检测用的模型
|
|
8
|
+
*/
|
|
9
|
+
export default class EventMesh extends Mesh<BufferGeometry, Material> {
|
|
10
|
+
constructor(type?: CollisionShaere);
|
|
11
|
+
static type: typeof CollisionShaere;
|
|
12
|
+
static material: MeshNormalMaterial;
|
|
13
|
+
renderOrder: number;
|
|
14
|
+
static cubeGeo: BoxGeometry;
|
|
15
|
+
static cylinderGeo: CylinderGeometry;
|
|
16
|
+
isEventMesh: boolean;
|
|
17
|
+
setType(type: CollisionShaere): void;
|
|
18
|
+
}
|
package/EventMesh.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: xiaosihan
|
|
3
|
-
* @Date: 2022-03-20 12:55:37
|
|
4
|
-
* @Last Modified by: xiaosihan
|
|
5
|
-
* @Last Modified time: 2023-02-07 11:19:56
|
|
6
|
-
*/
|
|
7
|
-
import { BoxGeometry, CylinderGeometry, DoubleSide, Mesh, MeshBasicMaterial, MeshNormalMaterial } from "three";
|
|
8
|
-
import threeUtils from "./threeUtils";
|
|
9
|
-
// 碰撞的形状
|
|
10
|
-
export var CollisionShaere;
|
|
11
|
-
(function (CollisionShaere) {
|
|
12
|
-
CollisionShaere["cube"] = "cube";
|
|
13
|
-
CollisionShaere["cylinder"] = "cylinder"; // 圆柱体
|
|
14
|
-
})(CollisionShaere || (CollisionShaere = {}));
|
|
15
|
-
/**
|
|
16
|
-
* 碰撞检测用的模型
|
|
17
|
-
*/
|
|
18
|
-
export default class EventMesh extends Mesh {
|
|
19
|
-
constructor(type = CollisionShaere.cube) {
|
|
20
|
-
super();
|
|
21
|
-
this.material = EventMesh.material;
|
|
22
|
-
this.setType(type);
|
|
23
|
-
// 生产环境 不用渲染
|
|
24
|
-
if (threeUtils.isProd) {
|
|
25
|
-
this.material = new MeshBasicMaterial({
|
|
26
|
-
side: DoubleSide,
|
|
27
|
-
transparent: true,
|
|
28
|
-
opacity: 0.25,
|
|
29
|
-
alphaTest: 1
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
static type = CollisionShaere;
|
|
34
|
-
static material = new MeshNormalMaterial({
|
|
35
|
-
side: DoubleSide,
|
|
36
|
-
transparent: true,
|
|
37
|
-
opacity: 0.3,
|
|
38
|
-
});
|
|
39
|
-
renderOrder = 99;
|
|
40
|
-
// 正方体 网格模型
|
|
41
|
-
static cubeGeo = new BoxGeometry(1, 1, 1, 1, 1, 1);
|
|
42
|
-
// 圆柱体 网格模型
|
|
43
|
-
static cylinderGeo = new CylinderGeometry(1, 1, 1, 50, 1, false, 0, Math.PI * 2);
|
|
44
|
-
// 是否是碰撞检测专用的模型
|
|
45
|
-
isEventMesh = true;
|
|
46
|
-
setType(type) {
|
|
47
|
-
switch (type) {
|
|
48
|
-
case EventMesh.type.cube:
|
|
49
|
-
this.geometry = EventMesh.cubeGeo;
|
|
50
|
-
break;
|
|
51
|
-
case EventMesh.type.cylinder:
|
|
52
|
-
this.geometry = EventMesh.cylinderGeo;
|
|
53
|
-
break;
|
|
54
|
-
default:
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
this.geometry.computeVertexNormals();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* @Author: xiaosihan
|
|
3
|
+
* @Date: 2022-03-20 12:55:37
|
|
4
|
+
* @Last Modified by: xiaosihan
|
|
5
|
+
* @Last Modified time: 2023-02-07 11:19:56
|
|
6
|
+
*/
|
|
7
|
+
import { BoxGeometry, CylinderGeometry, DoubleSide, Mesh, MeshBasicMaterial, MeshNormalMaterial } from "three";
|
|
8
|
+
import threeUtils from "./threeUtils";
|
|
9
|
+
// 碰撞的形状
|
|
10
|
+
export var CollisionShaere;
|
|
11
|
+
(function (CollisionShaere) {
|
|
12
|
+
CollisionShaere["cube"] = "cube";
|
|
13
|
+
CollisionShaere["cylinder"] = "cylinder"; // 圆柱体
|
|
14
|
+
})(CollisionShaere || (CollisionShaere = {}));
|
|
15
|
+
/**
|
|
16
|
+
* 碰撞检测用的模型
|
|
17
|
+
*/
|
|
18
|
+
export default class EventMesh extends Mesh {
|
|
19
|
+
constructor(type = CollisionShaere.cube) {
|
|
20
|
+
super();
|
|
21
|
+
this.material = EventMesh.material;
|
|
22
|
+
this.setType(type);
|
|
23
|
+
// 生产环境 不用渲染
|
|
24
|
+
if (threeUtils.isProd) {
|
|
25
|
+
this.material = new MeshBasicMaterial({
|
|
26
|
+
side: DoubleSide,
|
|
27
|
+
transparent: true,
|
|
28
|
+
opacity: 0.25,
|
|
29
|
+
alphaTest: 1
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
static type = CollisionShaere;
|
|
34
|
+
static material = new MeshNormalMaterial({
|
|
35
|
+
side: DoubleSide,
|
|
36
|
+
transparent: true,
|
|
37
|
+
opacity: 0.3,
|
|
38
|
+
});
|
|
39
|
+
renderOrder = 99;
|
|
40
|
+
// 正方体 网格模型
|
|
41
|
+
static cubeGeo = new BoxGeometry(1, 1, 1, 1, 1, 1);
|
|
42
|
+
// 圆柱体 网格模型
|
|
43
|
+
static cylinderGeo = new CylinderGeometry(1, 1, 1, 50, 1, false, 0, Math.PI * 2);
|
|
44
|
+
// 是否是碰撞检测专用的模型
|
|
45
|
+
isEventMesh = true;
|
|
46
|
+
setType(type) {
|
|
47
|
+
switch (type) {
|
|
48
|
+
case EventMesh.type.cube:
|
|
49
|
+
this.geometry = EventMesh.cubeGeo;
|
|
50
|
+
break;
|
|
51
|
+
case EventMesh.type.cylinder:
|
|
52
|
+
this.geometry = EventMesh.cylinderGeo;
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
this.geometry.computeVertexNormals();
|
|
58
|
+
}
|
|
59
|
+
}
|