|
@@ -4,6 +4,11 @@ import BreathPoint from "./BreathPoint.js"
|
|
|
import Logger from "./Logger.js"
|
|
|
import XBreathPointError from "./Error/XBreathPointError.js"
|
|
|
|
|
|
+const pointsArr1 = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,144,145,146,147,148,149,150,151,152,153,154]
|
|
|
+const pointsArr2 = [61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181]
|
|
|
+const pointsArr3 = [106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226]
|
|
|
+const pointsArr4 = [133,134,135,136,137,138,139,140,141,142,143,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286]
|
|
|
+
|
|
|
const logger = new Logger('BreathPointManager')
|
|
|
export default class XBreathPointManager {
|
|
|
constructor(e) {
|
|
@@ -17,14 +22,20 @@ export default class XBreathPointManager {
|
|
|
const t = [{
|
|
|
// url: "https://static.xverse.cn/qqktv/texture.png"
|
|
|
url: "./assets/textures/breathPoint/texture.png"
|
|
|
+ },{
|
|
|
+ url: "./assets/textures/breathPoint/texture_yellow.png"
|
|
|
+ },{
|
|
|
+ url: "./assets/textures/breathPoint/texture_purple.png"
|
|
|
+ },{
|
|
|
+ url: "./assets/textures/breathPoint/texture_green.png",
|
|
|
}];
|
|
|
if (t.length <= 0) {
|
|
|
logger.warn("[Engine] BreathPoint get texture list error: textureList.length <= 0"),
|
|
|
new XBreathPointError("[Engine] BreathPoint get texture list error!");
|
|
|
return
|
|
|
}
|
|
|
- const r = t[0]
|
|
|
- , {
|
|
|
+ let r = t[1]
|
|
|
+ let {
|
|
|
id, spriteSheet=r.url, spriteWidthNumber=20, spriteHeightNumber=1, position, rotation={ pitch: -90, yaw: 270, roll: 0 },
|
|
|
size=.6, width=-1, height=-1, fps=30, billboardMode=!1, forceLeaveGround=!1, type="default", lifeTime=-1, backfaceculling=!0,
|
|
|
maxVisibleRegion=-1, skinInfo="default"
|
|
@@ -40,6 +51,10 @@ export default class XBreathPointManager {
|
|
|
I != 0 ? position.z = position.z - I + 1 : position.z = position.z + 1
|
|
|
}
|
|
|
|
|
|
+ if(pointsArr1.indexOf(parseInt(id)) > -1) type = "p1"
|
|
|
+ if(pointsArr2.indexOf(parseInt(id)) > -1) type = "p2"
|
|
|
+ if(pointsArr3.indexOf(parseInt(id)) > -1) type = "p3"
|
|
|
+
|
|
|
let mat;
|
|
|
if (this.materialMap.get(type)) {
|
|
|
const I = this.materialMap.get(type);
|
|
@@ -52,13 +67,19 @@ export default class XBreathPointManager {
|
|
|
} ,null, !0);
|
|
|
texture.name = "TexBreathPoint_" + id,
|
|
|
|
|
|
- mat = new BABYLON.StandardMaterial(`MaterialBreathPoint_${id}`,this._scene),
|
|
|
- mat.alpha = 1,
|
|
|
- mat.emissiveTexture = texture,
|
|
|
- mat.backFaceCulling = backfaceculling,
|
|
|
- mat.diffuseTexture = texture,
|
|
|
- mat.diffuseTexture.hasAlpha = !0,
|
|
|
- mat.useAlphaFromDiffuseTexture = !0,
|
|
|
+ mat = new BABYLON.StandardMaterial(`MaterialBreathPoint_${id}`,this._scene)
|
|
|
+ // todo 暂改
|
|
|
+ // mat.alpha = 1,
|
|
|
+ // mat.emissiveTexture = texture,
|
|
|
+ // mat.backFaceCulling = backfaceculling,
|
|
|
+ // mat.diffuseTexture = texture,
|
|
|
+ // mat.diffuseTexture.hasAlpha = !0,
|
|
|
+ // mat.useAlphaFromDiffuseTexture = !0,
|
|
|
+ if(type == "p1") mat.emissiveColor.set(1,1,1)
|
|
|
+ else if(type == "p2") mat.emissiveColor.set(1,1,0.5)
|
|
|
+ else if(type == "p3") mat.emissiveColor.set(1,0.5,0)
|
|
|
+ else mat.emissiveColor.set(1,0,0)
|
|
|
+
|
|
|
this.materialMap.set(type, {
|
|
|
mat,
|
|
|
count: 1,
|
|
@@ -123,6 +144,47 @@ export default class XBreathPointManager {
|
|
|
lifeTime > 0 && setTimeout(()=>{
|
|
|
this.clearBreathPoints(id)
|
|
|
}, lifeTime * 1e3)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(debugMode) {
|
|
|
+ var textureBPNum = new BABYLON.DynamicTexture("dynamic_texture_" + id, {width:300, height:150}, this._scene);
|
|
|
+ textureBPNum.drawText(id, 0, 150, "bold 200px monospace", "white", "", true, true);
|
|
|
+ var materialBPNum = new BABYLON.StandardMaterial("MatBPNum_" + id, this._scene);
|
|
|
+ materialBPNum.diffuseTexture = textureBPNum;
|
|
|
+ materialBPNum.emissiveTexture = textureBPNum;
|
|
|
+ materialBPNum.diffuseTexture.hasAlpha = !0
|
|
|
+ materialBPNum.useAlphaFromDiffuseTexture = !0
|
|
|
+ materialBPNum.zOffset = -4
|
|
|
+
|
|
|
+ var bpNumMesh
|
|
|
+ if(this.bpNumMesh) {
|
|
|
+ bpNumMesh = this.bpNumMesh.clone("BreathPointNum_" + id)
|
|
|
+ } else {
|
|
|
+ bpNumMesh = BABYLON.MeshBuilder.CreatePlane("BreathPointNum_" + id, {width: 0.4, height: 0.2, subdivisions: 1}, this._scene);
|
|
|
+ bpNumMesh.rotation = new BABYLON.Vector3(Math.PI / 2, 0, 0)
|
|
|
+ this.bpNumMesh = bpNumMesh
|
|
|
+ }
|
|
|
+ bpNumMesh.position = mesh.position
|
|
|
+ bpNumMesh.material = materialBPNum;
|
|
|
+
|
|
|
+ // let standardVec = BABYLON.Vector3.Project(
|
|
|
+ // mesh.position,
|
|
|
+ // BABYLON.Matrix.Identity(),
|
|
|
+ // this._scene.getViewMatrix(),
|
|
|
+ // this._scene.getProjectionMatrix()
|
|
|
+ // )
|
|
|
+ // console.error(standardVec)
|
|
|
+ // let screenX = Math.round(window.innerWidth / 2 * standardVec.x + window.innerWidth / 2)
|
|
|
+ // let screenY = Math.round(window.innerHeight / 2 * standardVec.y + window.innerHeight / 2)
|
|
|
+ // let idContant = document.createElement("div")
|
|
|
+ // idContant.innerHTML = id
|
|
|
+ // idContant.style.position = "absolute"
|
|
|
+ // idContant.style.top = screenY + "px"
|
|
|
+ // idContant.style.left = screenX + "px"
|
|
|
+ // document.querySelector("#root").appendChild(idContant)
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
|
|
|
E(this, "reg_breathpoint_update", ()=>{
|
|
@@ -155,7 +217,8 @@ export default class XBreathPointManager {
|
|
|
);
|
|
|
this._sceneManager = e,
|
|
|
this._scene = e.Scene,
|
|
|
- this._scene.registerBeforeRender(this.reg_breathpoint_update),
|
|
|
+ // todo 暂改
|
|
|
+ // this._scene.registerBeforeRender(this.reg_breathpoint_update),
|
|
|
this._scene.registerBeforeRender(this.reg_breathpoint_autovisible)
|
|
|
}
|
|
|
setAllBreathPointVisibility(e) {
|