three-base 1.0.82 → 1.0.84
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/index.js +1 -1
- package/index.ts +1 -1
- package/lib/ApngTexture.js +40 -107
- package/lib/ApngTextureManage.js +51 -100
- package/lib/EventMesh.js +22 -42
- package/lib/ExtrudeMesh.js +147 -178
- package/lib/FPScontrol.js +116 -133
- package/lib/InstancedGroupMesh.js +25 -45
- package/lib/KeyFrameAnimation.js +37 -54
- package/lib/PlaneText.d.ts +2 -2
- package/lib/PlaneText.js +16 -36
- package/lib/PlaneText.ts +2 -3
- package/lib/PlaneWithHtml.js +48 -126
- package/lib/PointLight/PointLight.d.ts +2 -2
- package/lib/PointLight/PointLight.js +47 -67
- package/lib/PointLight/PointLight.ts +3 -3
- package/lib/Sky/Sky.js +11 -30
- package/lib/SpriteText.d.ts +45 -0
- package/lib/SpriteText.js +162 -0
- package/lib/SpriteText.ts +189 -0
- package/lib/SpriteText2.d.ts +4 -4
- package/lib/SpriteText2.js +90 -166
- package/lib/Text3D/Text3D.js +40 -61
- package/lib/Text3D/fontController.js +149 -284
- package/lib/ThreeBase.js +204 -341
- package/lib/ThreeMouse.js +244 -203
- package/lib/Transition.js +95 -161
- package/lib/keyContorls.js +74 -102
- package/lib/planeModal1/PlaneModal1.js +90 -162
- package/lib/shaders.js +178 -36
- package/lib/spriteModal1/SpriteModal1.js +93 -165
- package/lib/threeLoader.js +66 -89
- package/lib/threeUtils.js +61 -85
- package/lib/threeUtils.ts +2 -1
- package/package.json +3 -5
package/index.js
CHANGED
|
@@ -25,7 +25,7 @@ export { default as FPScontrol } from "./lib/FPScontrol";
|
|
|
25
25
|
// 平面文字
|
|
26
26
|
export { default as PlaneText } from "./lib/PlaneText";
|
|
27
27
|
// 精灵文字
|
|
28
|
-
export { default as SpriteText } from "
|
|
28
|
+
export { default as SpriteText } from "./lib/SpriteText";
|
|
29
29
|
// 精灵文字样式2
|
|
30
30
|
export { default as SpriteText2 } from "./lib/SpriteText2";
|
|
31
31
|
//精灵文本框
|
package/index.ts
CHANGED
|
@@ -43,7 +43,7 @@ export { default as FPScontrol } from "./lib/FPScontrol";
|
|
|
43
43
|
export { default as PlaneText } from "./lib/PlaneText";
|
|
44
44
|
|
|
45
45
|
// 精灵文字
|
|
46
|
-
export { default as SpriteText } from "
|
|
46
|
+
export { default as SpriteText } from "./lib/SpriteText";
|
|
47
47
|
|
|
48
48
|
// 精灵文字样式2
|
|
49
49
|
export { default as SpriteText2 } from "./lib/SpriteText2";
|
package/lib/ApngTexture.js
CHANGED
|
@@ -1,82 +1,34 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
-
function step(op) {
|
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
-
switch (op[0]) {
|
|
35
|
-
case 0: case 1: t = op; break;
|
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
46
|
-
}
|
|
47
|
-
op = body.call(thisArg, _);
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
1
|
import parseAPNG from "apng-js";
|
|
53
2
|
import axios from "axios";
|
|
54
3
|
import { CanvasTexture } from "three";
|
|
55
4
|
import threeUtils from "./threeUtils";
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// 上一次更新时间
|
|
61
|
-
_this.preUpdate = 0;
|
|
62
|
-
// 更新纹理
|
|
63
|
-
_this.onUpdate = function () {
|
|
64
|
-
if (_this.preUpdate === ApngTexture.TimeTemp) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
_this.preUpdate = ApngTexture.TimeTemp;
|
|
68
|
-
if (_this.player) {
|
|
69
|
-
_this.player.renderNextFrame();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
_this.loadApng(url);
|
|
73
|
-
return _this;
|
|
5
|
+
export default class ApngTexture extends CanvasTexture {
|
|
6
|
+
constructor(url) {
|
|
7
|
+
super(document.createElement("canvas"));
|
|
8
|
+
this.loadApng(url);
|
|
74
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
|
+
};
|
|
75
27
|
// 获取当前帧id
|
|
76
|
-
|
|
28
|
+
getUuid() {
|
|
77
29
|
if (this.apng) {
|
|
78
|
-
|
|
79
|
-
|
|
30
|
+
let currentTime = ApngTexture.TimeTemp % this.apng.playTime;
|
|
31
|
+
let i = 0;
|
|
80
32
|
while (this.apng.frames[i] && currentTime > this.apng.frames[i].delay) {
|
|
81
33
|
currentTime -= this.apng.frames[i].delay;
|
|
82
34
|
i++;
|
|
@@ -86,43 +38,24 @@ var ApngTexture = /** @class */ (function (_super) {
|
|
|
86
38
|
else {
|
|
87
39
|
return "";
|
|
88
40
|
}
|
|
89
|
-
}
|
|
41
|
+
}
|
|
90
42
|
// 加载apng图片
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
res = _b.sent();
|
|
99
|
-
blob = new Blob([res.data]);
|
|
100
|
-
reader = new FileReader();
|
|
101
|
-
return [4 /*yield*/, new Promise(function (resolve) {
|
|
102
|
-
reader.onload = function () { return resolve(); };
|
|
103
|
-
reader.readAsArrayBuffer(blob);
|
|
104
|
-
})];
|
|
105
|
-
case 2:
|
|
106
|
-
_b.sent();
|
|
107
|
-
apng = parseAPNG(reader.result);
|
|
108
|
-
this.dispose();
|
|
109
|
-
this.image.width = apng.width;
|
|
110
|
-
this.image.height = apng.height;
|
|
111
|
-
_a = this;
|
|
112
|
-
return [4 /*yield*/, apng.getPlayer(this.image.getContext("2d"))];
|
|
113
|
-
case 3:
|
|
114
|
-
_a.player = _b.sent();
|
|
115
|
-
return [2 /*return*/];
|
|
116
|
-
}
|
|
117
|
-
});
|
|
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);
|
|
118
50
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
+
}
|
|
125
58
|
// 定时更新时间戳
|
|
126
|
-
threeUtils.addEventListener("requestAnimationFrame",
|
|
59
|
+
threeUtils.addEventListener("requestAnimationFrame", (e) => {
|
|
127
60
|
ApngTexture.TimeTemp = e.timeTemp;
|
|
128
61
|
});
|
package/lib/ApngTextureManage.js
CHANGED
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
1
|
import parseAPNG from "apng-js";
|
|
38
2
|
import axios from "axios";
|
|
39
3
|
import { isEmpty } from "lodash";
|
|
@@ -42,22 +6,26 @@ import threeUtils from "./threeUtils";
|
|
|
42
6
|
/**
|
|
43
7
|
* apng 纹理管理对象
|
|
44
8
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// 每个动态纹理的播放总时长
|
|
48
|
-
this.playTimes = new Map();
|
|
49
|
-
// 保存所有的动态纹理
|
|
50
|
-
this.anpgTextList = {};
|
|
9
|
+
class apngTextureManage {
|
|
10
|
+
constructor() {
|
|
51
11
|
// 初始化定时更新时间戳
|
|
52
12
|
if (apngTextureManage.isInit) {
|
|
53
13
|
apngTextureManage.isInit = false;
|
|
54
|
-
threeUtils.addEventListener("requestAnimationFrame5000",
|
|
14
|
+
threeUtils.addEventListener("requestAnimationFrame5000", (e) => {
|
|
55
15
|
apngTextureManage.TimeTemp = e.timeTemp;
|
|
56
16
|
});
|
|
57
17
|
}
|
|
58
18
|
}
|
|
19
|
+
static TextureLoader = new TextureLoader();
|
|
20
|
+
static isInit = true;
|
|
21
|
+
// 获取时间戳
|
|
22
|
+
static TimeTemp = performance.now();
|
|
23
|
+
// 每个动态纹理的播放总时长
|
|
24
|
+
playTimes = new Map();
|
|
25
|
+
// 保存所有的动态纹理
|
|
26
|
+
anpgTextList = {};
|
|
59
27
|
// 获取动态纹理 需要每帧都获取一下
|
|
60
|
-
|
|
28
|
+
getTexture(path) {
|
|
61
29
|
// 如果 没有这个纹理就返回空同时开始加载这个纹理
|
|
62
30
|
if (!this.anpgTextList[path]) {
|
|
63
31
|
this.anpgTextList[path] = [];
|
|
@@ -68,9 +36,9 @@ var apngTextureManage = /** @class */ (function () {
|
|
|
68
36
|
return null;
|
|
69
37
|
}
|
|
70
38
|
else {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
39
|
+
const playTime = this.playTimes.get(path);
|
|
40
|
+
let currentTime = apngTextureManage.TimeTemp % playTime;
|
|
41
|
+
let i = 0;
|
|
74
42
|
while (this.anpgTextList[path][i] && currentTime > Number(this.anpgTextList[path][i].name)) {
|
|
75
43
|
currentTime -= Number(this.anpgTextList[path][i].name);
|
|
76
44
|
i++;
|
|
@@ -78,59 +46,42 @@ var apngTextureManage = /** @class */ (function () {
|
|
|
78
46
|
this.anpgTextList[path][i].needsUpdate = true;
|
|
79
47
|
return this.anpgTextList[path][i];
|
|
80
48
|
}
|
|
81
|
-
}
|
|
49
|
+
}
|
|
82
50
|
// 加载apng图片
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
res = _a.sent();
|
|
91
|
-
blob = new Blob([res.data]);
|
|
92
|
-
reader = new FileReader();
|
|
93
|
-
return [4 /*yield*/, new Promise(function (resolve) {
|
|
94
|
-
reader.onload = function () { return resolve(); };
|
|
95
|
-
reader.readAsArrayBuffer(blob);
|
|
96
|
-
})];
|
|
97
|
-
case 2:
|
|
98
|
-
_a.sent();
|
|
99
|
-
apng = parseAPNG(reader.result);
|
|
100
|
-
// 存储播放时长
|
|
101
|
-
this.playTimes.set(url, apng.playTime);
|
|
102
|
-
// for (let i = 0; i < apng.frames.length; i++) {
|
|
103
|
-
// const frame = apng.frames[i];
|
|
104
|
-
// frame.createImage();
|
|
105
|
-
// await new Promise(resolve => frame.imageElement!.onload = resolve);
|
|
106
|
-
// }
|
|
107
|
-
for (i = 0; i < apng.frames.length; i++) {
|
|
108
|
-
frame = apng.frames[i];
|
|
109
|
-
blobUrl = URL.createObjectURL(frame.imageData);
|
|
110
|
-
texture = apngTextureManage.TextureLoader.load(blobUrl);
|
|
111
|
-
texture.anisotropy = 16;
|
|
112
|
-
texture.wrapS = texture.wrapT = MirroredRepeatWrapping;
|
|
113
|
-
// export const RepeatWrapping: Wrapping;
|
|
114
|
-
// export const ClampToEdgeWrapping: Wrapping;
|
|
115
|
-
// export const MirroredRepeatWrapping: Wrapping;
|
|
116
|
-
// magFilter: TextureFilter;
|
|
117
|
-
// minFilter: TextureFilter;
|
|
118
|
-
texture.name = String(frame.delay);
|
|
119
|
-
texture.center.set(0.5, 0.5);
|
|
120
|
-
texture.repeat.set(apng.width / frame.width, apng.height / frame.height);
|
|
121
|
-
// texture.needsUpdate = true;
|
|
122
|
-
this.anpgTextList[url].push(texture);
|
|
123
|
-
}
|
|
124
|
-
return [2 /*return*/];
|
|
125
|
-
}
|
|
126
|
-
});
|
|
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);
|
|
127
58
|
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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();
|
|
136
87
|
export default ApngTextureManage;
|
package/lib/EventMesh.js
CHANGED
|
@@ -4,21 +4,6 @@
|
|
|
4
4
|
* @Last Modified by: xiaosihan
|
|
5
5
|
* @Last Modified time: 2023-02-07 11:19:56
|
|
6
6
|
*/
|
|
7
|
-
var __extends = (this && this.__extends) || (function () {
|
|
8
|
-
var extendStatics = function (d, b) {
|
|
9
|
-
extendStatics = Object.setPrototypeOf ||
|
|
10
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
11
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
12
|
-
return extendStatics(d, b);
|
|
13
|
-
};
|
|
14
|
-
return function (d, b) {
|
|
15
|
-
if (typeof b !== "function" && b !== null)
|
|
16
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
17
|
-
extendStatics(d, b);
|
|
18
|
-
function __() { this.constructor = d; }
|
|
19
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
20
|
-
};
|
|
21
|
-
})();
|
|
22
7
|
import { BoxGeometry, CylinderGeometry, DoubleSide, Mesh, MeshBasicMaterial, MeshNormalMaterial } from "three";
|
|
23
8
|
import threeUtils from "./threeUtils";
|
|
24
9
|
// 碰撞的形状
|
|
@@ -30,28 +15,35 @@ export var CollisionShaere;
|
|
|
30
15
|
/**
|
|
31
16
|
* 碰撞检测用的模型
|
|
32
17
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
_this.renderOrder = 99;
|
|
39
|
-
// 是否是碰撞检测专用的模型
|
|
40
|
-
_this.isEventMesh = true;
|
|
41
|
-
_this.material = EventMesh.material;
|
|
42
|
-
_this.setType(type);
|
|
18
|
+
export default class EventMesh extends Mesh {
|
|
19
|
+
constructor(type = CollisionShaere.cube) {
|
|
20
|
+
super();
|
|
21
|
+
this.material = EventMesh.material;
|
|
22
|
+
this.setType(type);
|
|
43
23
|
// 生产环境 不用渲染
|
|
44
24
|
if (threeUtils.isProd) {
|
|
45
|
-
|
|
25
|
+
this.material = new MeshBasicMaterial({
|
|
46
26
|
side: DoubleSide,
|
|
47
27
|
transparent: true,
|
|
48
28
|
opacity: 0.25,
|
|
49
29
|
alphaTest: 1
|
|
50
30
|
});
|
|
51
31
|
}
|
|
52
|
-
return _this;
|
|
53
32
|
}
|
|
54
|
-
|
|
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) {
|
|
55
47
|
switch (type) {
|
|
56
48
|
case EventMesh.type.cube:
|
|
57
49
|
this.geometry = EventMesh.cubeGeo;
|
|
@@ -63,17 +55,5 @@ var EventMesh = /** @class */ (function (_super) {
|
|
|
63
55
|
break;
|
|
64
56
|
}
|
|
65
57
|
this.geometry.computeVertexNormals();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
EventMesh.material = new MeshNormalMaterial({
|
|
69
|
-
side: DoubleSide,
|
|
70
|
-
transparent: true,
|
|
71
|
-
opacity: 0.3,
|
|
72
|
-
});
|
|
73
|
-
// 正方体 网格模型
|
|
74
|
-
EventMesh.cubeGeo = new BoxGeometry(1, 1, 1, 1, 1, 1);
|
|
75
|
-
// 圆柱体 网格模型
|
|
76
|
-
EventMesh.cylinderGeo = new CylinderGeometry(1, 1, 1, 50, 1, false, 0, Math.PI * 2);
|
|
77
|
-
return EventMesh;
|
|
78
|
-
}(Mesh));
|
|
79
|
-
export default EventMesh;
|
|
58
|
+
}
|
|
59
|
+
}
|