three-base 2.0.65 → 2.0.67
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/EventMesh.d.ts +18 -18
- package/EventMesh.js +59 -59
- package/ExtrudeMesh.d.ts +111 -111
- package/ExtrudeMesh.js +363 -363
- package/FPScontrol.d.ts +45 -45
- package/FPScontrol.js +171 -171
- 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/InstancedMeshBase.d.ts +24 -24
- package/InstancedMeshBase.js +190 -190
- package/KeyFrameAnimation.d.ts +25 -25
- package/KeyFrameAnimation.js +78 -78
- package/MeshBase.d.ts +32 -32
- package/MeshBase.js +172 -172
- package/Mirror.d.ts +25 -25
- package/Mirror.js +139 -139
- 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 +44 -44
- package/PlaneText.js +30 -30
- package/PlaneWithHtml.d.ts +11 -11
- package/PlaneWithHtml.js +68 -68
- package/PointLight/PointLight.d.ts +13 -13
- package/PointLight/PointLight.js +64 -64
- package/PointLight/index.d.ts +1 -1
- package/PointLight/index.js +1 -1
- package/Sky/Sky.d.ts +13 -13
- package/Sky/Sky.js +28 -28
- package/Sky/index.d.ts +1 -1
- package/Sky/index.js +1 -1
- 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 +49 -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 +200 -200
- package/Text3D/index.d.ts +1 -1
- package/Text3D/index.js +1 -1
- package/ThreeBase.d.ts +91 -91
- package/ThreeBase.js +611 -611
- package/ThreeBase.ts +2 -2
- package/ThreeMouse.d.ts +39 -39
- package/ThreeMouse.js +359 -359
- package/Transition.d.ts +40 -40
- package/Transition.js +207 -207
- 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/FullScreenQuad.d.ts +7 -7
- package/pass/FullScreenQuad.js +25 -25
- package/pass/glow_pass.d.ts +2 -2
- package/pass/glow_pass.js +236 -236
- package/pass/stroke_pass.d.ts +2 -2
- package/pass/stroke_pass.js +202 -202
- package/shaders/FXAAShaderMaterial.d.ts +3 -3
- package/shaders/FXAAShaderMaterial.js +21 -21
- package/shaders.d.ts +17 -17
- package/shaders.js +99 -99
- package/threeLoader.d.ts +26 -26
- package/threeLoader.js +189 -174
- package/threeLoader.ts +17 -1
- package/threeUtils.d.ts +47 -47
- package/threeUtils.js +266 -266
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;
|
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
|
+
}
|