@celljs/ta-earth 4.31.0 → 4.32.0
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/README.en.md +1 -1
- package/README.md +2 -2
- package/package.json +6 -6
- package/play/page.html +204 -197
- package/web/index.js +241 -32
package/web/index.js
CHANGED
|
@@ -1096,6 +1096,7 @@ var GeoMvt;
|
|
|
1096
1096
|
// ../ta-geo/esm/geo-tiles.js
|
|
1097
1097
|
var GZIP = [31, 139];
|
|
1098
1098
|
var KEPT = 8;
|
|
1099
|
+
var WAIT_MS = 15000;
|
|
1099
1100
|
async function gunzip(bytes) {
|
|
1100
1101
|
if (bytes[0] !== GZIP[0] || bytes[1] !== GZIP[1]) {
|
|
1101
1102
|
return bytes;
|
|
@@ -1105,9 +1106,10 @@ async function gunzip(bytes) {
|
|
|
1105
1106
|
}
|
|
1106
1107
|
|
|
1107
1108
|
class OpenFreeMapTiles {
|
|
1108
|
-
constructor(fetcher = (url, init) => fetch(url, init), base = "https://tiles.openfreemap.org/planet") {
|
|
1109
|
+
constructor(fetcher = (url, init) => fetch(url, init), base = "https://tiles.openfreemap.org/planet", wait = WAIT_MS) {
|
|
1109
1110
|
this.fetcher = fetcher;
|
|
1110
1111
|
this.base = base;
|
|
1112
|
+
this.wait = wait;
|
|
1111
1113
|
this.maxZoom = 14;
|
|
1112
1114
|
this.kept = new Map;
|
|
1113
1115
|
}
|
|
@@ -1122,7 +1124,7 @@ class OpenFreeMapTiles {
|
|
|
1122
1124
|
this.kept.set(key, kept);
|
|
1123
1125
|
return kept;
|
|
1124
1126
|
}
|
|
1125
|
-
const made = this.load(tile, version);
|
|
1127
|
+
const made = this.within((signal) => this.load(tile, version, signal), `Map tile ${tile.z}/${tile.x}/${tile.y}`);
|
|
1126
1128
|
made.catch(() => this.kept.delete(key));
|
|
1127
1129
|
this.kept.set(key, made);
|
|
1128
1130
|
while (this.kept.size > KEPT) {
|
|
@@ -1130,12 +1132,12 @@ class OpenFreeMapTiles {
|
|
|
1130
1132
|
}
|
|
1131
1133
|
return made;
|
|
1132
1134
|
}
|
|
1133
|
-
async load(tile, version) {
|
|
1135
|
+
async load(tile, version, signal) {
|
|
1134
1136
|
const { template, version: latest } = await this.read();
|
|
1135
1137
|
const url = (of) => template.replace(latest, of).replace("{z}", String(tile.z)).replace("{x}", String(tile.x)).replace("{y}", String(tile.y));
|
|
1136
|
-
let response = await this.fetcher(url(version));
|
|
1138
|
+
let response = await this.fetcher(url(version), { signal });
|
|
1137
1139
|
if (response.status === 404 && version !== latest) {
|
|
1138
|
-
response = await this.fetcher(url(latest));
|
|
1140
|
+
response = await this.fetcher(url(latest), { signal });
|
|
1139
1141
|
}
|
|
1140
1142
|
if (response.status === 204 || response.status === 404) {
|
|
1141
1143
|
return;
|
|
@@ -1148,7 +1150,7 @@ class OpenFreeMapTiles {
|
|
|
1148
1150
|
}
|
|
1149
1151
|
read() {
|
|
1150
1152
|
var _a;
|
|
1151
|
-
(_a = this.version) !== null && _a !== undefined || (this.version = this.fetcher(this.base).then((response) => {
|
|
1153
|
+
(_a = this.version) !== null && _a !== undefined || (this.version = this.within((signal) => this.fetcher(this.base, { signal }), "Map source").then((response) => {
|
|
1152
1154
|
if (!response.ok) {
|
|
1153
1155
|
throw new Error(`Map source: HTTP ${response.status}`);
|
|
1154
1156
|
}
|
|
@@ -1167,6 +1169,21 @@ class OpenFreeMapTiles {
|
|
|
1167
1169
|
});
|
|
1168
1170
|
return this.version;
|
|
1169
1171
|
}
|
|
1172
|
+
async within(work, what) {
|
|
1173
|
+
const controller = new AbortController;
|
|
1174
|
+
let timer;
|
|
1175
|
+
const late = new Promise((_, reject) => {
|
|
1176
|
+
timer = setTimeout(() => {
|
|
1177
|
+
controller.abort();
|
|
1178
|
+
reject(new Error(`${what}: no answer in ${Math.round(this.wait / 1000)} s`));
|
|
1179
|
+
}, this.wait);
|
|
1180
|
+
});
|
|
1181
|
+
try {
|
|
1182
|
+
return await Promise.race([work(controller.signal), late]);
|
|
1183
|
+
} finally {
|
|
1184
|
+
clearTimeout(timer);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1170
1187
|
}
|
|
1171
1188
|
|
|
1172
1189
|
// ../ta-geo/esm/geo-pixels.js
|
|
@@ -3219,6 +3236,8 @@ var EN3 = {
|
|
|
3219
3236
|
metres: "{count} m",
|
|
3220
3237
|
kilometres: "{count} km",
|
|
3221
3238
|
centreMe: "Back to me",
|
|
3239
|
+
goTo: "Go to {name}",
|
|
3240
|
+
meet: "Go to them",
|
|
3222
3241
|
sink: "Down",
|
|
3223
3242
|
flying: "Flying",
|
|
3224
3243
|
weatherNow: "{temperature}° {kind}",
|
|
@@ -3319,6 +3338,8 @@ var ZH3 = {
|
|
|
3319
3338
|
metres: "{count} 米",
|
|
3320
3339
|
kilometres: "{count} 公里",
|
|
3321
3340
|
centreMe: "回到我",
|
|
3341
|
+
goTo: "去{name}身边",
|
|
3342
|
+
meet: "瞬移过去",
|
|
3322
3343
|
weatherNow: "{temperature}° {kind}",
|
|
3323
3344
|
weather: { clear: "晴", cloudy: "多云", overcast: "阴", fog: "雾", drizzle: "毛毛雨", rain: "雨", snow: "雪", storm: "雷雨" },
|
|
3324
3345
|
tipsKeys: "WASD 走 · 空格跳 · 点人就能对话 · B 建造(左键挖、右键放、1–9 选方块)· Q 起飞/降落 · 飞行时空格升、Shift 降 · V 切换视角 · + − 调飞行速度 · M 地图 · Esc 放开鼠标",
|
|
@@ -3408,6 +3429,8 @@ var ZH_TW3 = {
|
|
|
3408
3429
|
metres: "{count} 公尺",
|
|
3409
3430
|
kilometres: "{count} 公里",
|
|
3410
3431
|
centreMe: "回到我",
|
|
3432
|
+
goTo: "去{name}身邊",
|
|
3433
|
+
meet: "瞬移過去",
|
|
3411
3434
|
weatherNow: "{temperature}° {kind}",
|
|
3412
3435
|
weather: { clear: "晴", cloudy: "多雲", overcast: "陰", fog: "霧", drizzle: "毛毛雨", rain: "雨", snow: "雪", storm: "雷雨" },
|
|
3413
3436
|
tipsKeys: "WASD 走 · 空白鍵跳 · 點人就能對話 · B 建造(左鍵挖、右鍵放、1–9 選方塊)· Q 起飛/降落 · 飛行時空白鍵升、Shift 降 · V 切換視角 · + − 調飛行速度 · M 地圖 · Esc 放開滑鼠",
|
|
@@ -3495,6 +3518,8 @@ var JA3 = {
|
|
|
3495
3518
|
metres: "{count} m",
|
|
3496
3519
|
kilometres: "{count} km",
|
|
3497
3520
|
centreMe: "自分の位置へ",
|
|
3521
|
+
goTo: "{name} のところへ",
|
|
3522
|
+
meet: "そこへ行く",
|
|
3498
3523
|
sink: "下降",
|
|
3499
3524
|
flying: "飛行中",
|
|
3500
3525
|
weatherNow: "{temperature}° {kind}",
|
|
@@ -4619,7 +4644,7 @@ var COLOURS = {
|
|
|
4619
4644
|
};
|
|
4620
4645
|
var EarthMap;
|
|
4621
4646
|
((EarthMap) => {
|
|
4622
|
-
function draw(canvas, rasters, at, yaw, span, island, dots, office) {
|
|
4647
|
+
function draw(canvas, rasters, at, yaw, span, island, dots, office, people = []) {
|
|
4623
4648
|
const context = canvas.getContext("2d");
|
|
4624
4649
|
if (!context) {
|
|
4625
4650
|
return;
|
|
@@ -4630,6 +4655,7 @@ var EarthMap;
|
|
|
4630
4655
|
const top = at.z - span / 2;
|
|
4631
4656
|
paint(context, size, size, rasters, left, top, per);
|
|
4632
4657
|
marks(context, { left, top, per }, island, dots, office);
|
|
4658
|
+
others(context, { left, top, per }, people, { width: size, height: size, edge: true });
|
|
4633
4659
|
arrow(context, size / 2, size / 2, yaw);
|
|
4634
4660
|
}
|
|
4635
4661
|
EarthMap.draw = draw;
|
|
@@ -4720,6 +4746,29 @@ var EarthMap;
|
|
|
4720
4746
|
}
|
|
4721
4747
|
}
|
|
4722
4748
|
EarthMap.marks = marks;
|
|
4749
|
+
function others(context, { left, top, per }, people, { width, height, edge = false, scale = 1 }) {
|
|
4750
|
+
const margin = 6 * scale;
|
|
4751
|
+
for (const one of people) {
|
|
4752
|
+
let x = (one.x - left) / per;
|
|
4753
|
+
let y = (one.z - top) / per;
|
|
4754
|
+
const outside = x < margin || y < margin || x > width - margin || y > height - margin;
|
|
4755
|
+
if (outside && !edge) {
|
|
4756
|
+
continue;
|
|
4757
|
+
}
|
|
4758
|
+
x = Math.max(margin, Math.min(width - margin, x));
|
|
4759
|
+
y = Math.max(margin, Math.min(height - margin, y));
|
|
4760
|
+
context.fillStyle = `#${one.color.toString(16).padStart(6, "0")}`;
|
|
4761
|
+
context.strokeStyle = "#ffffff";
|
|
4762
|
+
context.lineWidth = 2 * scale;
|
|
4763
|
+
context.globalAlpha = outside ? 0.75 : 1;
|
|
4764
|
+
context.beginPath();
|
|
4765
|
+
context.arc(x, y, 5 * scale, 0, Math.PI * 2);
|
|
4766
|
+
context.fill();
|
|
4767
|
+
context.stroke();
|
|
4768
|
+
context.globalAlpha = 1;
|
|
4769
|
+
}
|
|
4770
|
+
}
|
|
4771
|
+
EarthMap.others = others;
|
|
4723
4772
|
function arrow(context, x, y, yaw, scale = 1) {
|
|
4724
4773
|
context.save();
|
|
4725
4774
|
context.translate(x, y);
|
|
@@ -4745,11 +4794,23 @@ var EarthMap;
|
|
|
4745
4794
|
var SPANS = [384, 768, 1536, 3072, 6144];
|
|
4746
4795
|
var MAX_PIXELS = 560;
|
|
4747
4796
|
var DRAW_EVERY = 400;
|
|
4797
|
+
var OTHERS_EVERY = 1000;
|
|
4798
|
+
var hex = (color) => `#${color.toString(16).padStart(6, "0")}`;
|
|
4748
4799
|
function EarthBigMap({ ui, words: w, world, island, onClose }) {
|
|
4749
4800
|
const canvas = React.useRef(null);
|
|
4750
4801
|
const [zoom, setZoom] = React.useState(1);
|
|
4751
4802
|
const centre = React.useRef({ x: world.body.x, z: world.body.z });
|
|
4752
4803
|
const [pin, setPin] = React.useState();
|
|
4804
|
+
const [chosen, setChosen] = React.useState();
|
|
4805
|
+
const [others, setOthers] = React.useState(() => world.others());
|
|
4806
|
+
const names = React.useRef(new Map);
|
|
4807
|
+
React.useEffect(() => {
|
|
4808
|
+
const timer = setInterval(() => {
|
|
4809
|
+
const now = world.others();
|
|
4810
|
+
setOthers((before) => before.map((one) => `${one.id}:${one.name}`).join() === now.map((one) => `${one.id}:${one.name}`).join() ? before : now);
|
|
4811
|
+
}, OTHERS_EVERY);
|
|
4812
|
+
return () => clearInterval(timer);
|
|
4813
|
+
}, [world]);
|
|
4753
4814
|
const [, redraw] = React.useReducer((n) => n + 1, 0);
|
|
4754
4815
|
const pointers = React.useRef(new Map);
|
|
4755
4816
|
const gesture = React.useRef({ moved: 0, pinch: 0 });
|
|
@@ -4777,7 +4838,16 @@ function EarthBigMap({ ui, words: w, world, island, onClose }) {
|
|
|
4777
4838
|
const at = { left, top, per: per * scale };
|
|
4778
4839
|
EarthMap.paint(context, pw, ph, (px, pz) => world.plots.mapOf(px, pz), left, top, at.per);
|
|
4779
4840
|
EarthMap.marks(context, at, island, world.figures.where(), world.plan?.centre);
|
|
4841
|
+
const live = world.others();
|
|
4780
4842
|
EarthMap.arrow(context, (world.body.x - left) / at.per, (world.body.z - top) / at.per, world.controls.yaw, 1.2 / scale);
|
|
4843
|
+
for (const [id, element2] of names.current) {
|
|
4844
|
+
const one = live.find((each) => each.id === id);
|
|
4845
|
+
const x = one ? (one.x - left) / per : -1;
|
|
4846
|
+
const y = one ? (one.z - top) / per : -1;
|
|
4847
|
+
const shown = !!one && x >= 0 && y >= 0 && x <= width && y <= height;
|
|
4848
|
+
element2.style.display = shown ? "" : "none";
|
|
4849
|
+
element2.style.transform = `translate(${x}px, ${y}px)`;
|
|
4850
|
+
}
|
|
4781
4851
|
if (pin) {
|
|
4782
4852
|
const x = (pin.x - left) / at.per;
|
|
4783
4853
|
const y = (pin.z - top) / at.per;
|
|
@@ -4839,8 +4909,20 @@ function EarthBigMap({ ui, words: w, world, island, onClose }) {
|
|
|
4839
4909
|
return;
|
|
4840
4910
|
}
|
|
4841
4911
|
const { per, left, top } = frame();
|
|
4912
|
+
setChosen(undefined);
|
|
4842
4913
|
setPin({ x: left + at.x * per, z: top + at.y * per });
|
|
4843
4914
|
};
|
|
4915
|
+
const find = (id) => {
|
|
4916
|
+
const one = world.others().find((each) => each.id === id);
|
|
4917
|
+
if (!one) {
|
|
4918
|
+
return;
|
|
4919
|
+
}
|
|
4920
|
+
centre.current = { x: one.x, z: one.z };
|
|
4921
|
+
setPin(undefined);
|
|
4922
|
+
setChosen(id);
|
|
4923
|
+
redraw();
|
|
4924
|
+
};
|
|
4925
|
+
const friend = chosen ? world.others().find((each) => each.id === chosen) : undefined;
|
|
4844
4926
|
const wheel = React.useRef(0);
|
|
4845
4927
|
React.useEffect(() => {
|
|
4846
4928
|
const element = canvas.current;
|
|
@@ -4858,7 +4940,8 @@ function EarthBigMap({ ui, words: w, world, island, onClose }) {
|
|
|
4858
4940
|
element.addEventListener("wheel", onWheel, { passive: false });
|
|
4859
4941
|
return () => element.removeEventListener("wheel", onWheel);
|
|
4860
4942
|
}, []);
|
|
4861
|
-
const
|
|
4943
|
+
const target = friend ?? pin;
|
|
4944
|
+
const metres = target ? Math.hypot(target.x - world.body.x, target.z - world.body.z) * BLOCK_METRES : 0;
|
|
4862
4945
|
const distance = metres < 1000 ? EarthWords.format(w.metres, { count: Math.round(metres) }) : EarthWords.format(w.kilometres, { count: (metres / 1000).toFixed(1) });
|
|
4863
4946
|
const Back = ui.icons.ChevronLeft ?? ui.icons.X;
|
|
4864
4947
|
const Plus = ui.icons.Plus;
|
|
@@ -4884,7 +4967,31 @@ function EarthBigMap({ ui, words: w, world, island, onClose }) {
|
|
|
4884
4967
|
"aria-label": w.back
|
|
4885
4968
|
}, /* @__PURE__ */ React.createElement(Back, {
|
|
4886
4969
|
size: 18
|
|
4887
|
-
}), /* @__PURE__ */ React.createElement("span", null, w.bigMap))),
|
|
4970
|
+
}), /* @__PURE__ */ React.createElement("span", null, w.bigMap))), others.map((one) => /* @__PURE__ */ React.createElement("button", {
|
|
4971
|
+
key: one.id,
|
|
4972
|
+
type: "button",
|
|
4973
|
+
className: "tea-name",
|
|
4974
|
+
style: { display: "none" },
|
|
4975
|
+
ref: (element) => {
|
|
4976
|
+
if (element) {
|
|
4977
|
+
names.current.set(one.id, element);
|
|
4978
|
+
} else {
|
|
4979
|
+
names.current.delete(one.id);
|
|
4980
|
+
}
|
|
4981
|
+
},
|
|
4982
|
+
onClick: () => find(one.id)
|
|
4983
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
4984
|
+
style: { background: hex(one.color) }
|
|
4985
|
+
}), /* @__PURE__ */ React.createElement("span", null, one.name))), !pin && !friend && others.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
4986
|
+
className: "tea-people"
|
|
4987
|
+
}, others.map((one) => /* @__PURE__ */ React.createElement("button", {
|
|
4988
|
+
key: one.id,
|
|
4989
|
+
type: "button",
|
|
4990
|
+
className: "tew-chip tea-person",
|
|
4991
|
+
onClick: () => find(one.id)
|
|
4992
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
4993
|
+
style: { background: hex(one.color) }
|
|
4994
|
+
}), one.name))), !pin && !friend && others.length === 0 && /* @__PURE__ */ React.createElement("div", {
|
|
4888
4995
|
className: "tea-note"
|
|
4889
4996
|
}, w.bigMapHint), /* @__PURE__ */ React.createElement("div", {
|
|
4890
4997
|
className: "tea-zoom"
|
|
@@ -4915,7 +5022,32 @@ function EarthBigMap({ ui, words: w, world, island, onClose }) {
|
|
|
4915
5022
|
"aria-label": w.centreMe
|
|
4916
5023
|
}, Locate ? /* @__PURE__ */ React.createElement(Locate, {
|
|
4917
5024
|
size: 18
|
|
4918
|
-
}) : "◎")),
|
|
5025
|
+
}) : "◎")), friend && /* @__PURE__ */ React.createElement("div", {
|
|
5026
|
+
className: "tea-card"
|
|
5027
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
5028
|
+
className: "tea-card-head"
|
|
5029
|
+
}, /* @__PURE__ */ React.createElement("i", {
|
|
5030
|
+
className: "tea-dot tea-round",
|
|
5031
|
+
style: { background: hex(friend.color) }
|
|
5032
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
5033
|
+
className: "tea-card-title"
|
|
5034
|
+
}, friend.name)), /* @__PURE__ */ React.createElement("div", {
|
|
5035
|
+
className: "tea-card-line"
|
|
5036
|
+
}, EarthWords.format(w.goFar, { distance })), /* @__PURE__ */ React.createElement("div", {
|
|
5037
|
+
className: "ter-buttons"
|
|
5038
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
5039
|
+
type: "button",
|
|
5040
|
+
className: "ter-quiet",
|
|
5041
|
+
style: { margin: 0 },
|
|
5042
|
+
onClick: () => setChosen(undefined)
|
|
5043
|
+
}, w.cancel), /* @__PURE__ */ React.createElement("button", {
|
|
5044
|
+
type: "button",
|
|
5045
|
+
className: "ter-button",
|
|
5046
|
+
onClick: () => {
|
|
5047
|
+
world.meet(friend);
|
|
5048
|
+
onClose();
|
|
5049
|
+
}
|
|
5050
|
+
}, EarthWords.format(w.goTo, { name: friend.name })))), pin && /* @__PURE__ */ React.createElement("div", {
|
|
4919
5051
|
className: "tea-card"
|
|
4920
5052
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
4921
5053
|
className: "tea-card-line"
|
|
@@ -5290,7 +5422,7 @@ var RULES = [
|
|
|
5290
5422
|
["guestsPlay", "ruleGuestsPlay", false],
|
|
5291
5423
|
["guests", "ruleGuests", false]
|
|
5292
5424
|
];
|
|
5293
|
-
function EarthPeople({ ui, session, manage, words: w, shot, onClose }) {
|
|
5425
|
+
function EarthPeople({ ui, session, manage, words: w, shot, onMeet, onClose }) {
|
|
5294
5426
|
React.useSyncExternalStore(session.subscribe, session.snapshot);
|
|
5295
5427
|
const [busy, run] = (ui.useBusy ?? useOwnBusy)();
|
|
5296
5428
|
const [link, setLink] = React.useState();
|
|
@@ -5407,6 +5539,7 @@ function EarthPeople({ ui, session, manage, words: w, shot, onClose }) {
|
|
|
5407
5539
|
const looks = !member.owner && !member.admin && together.looks(member.member);
|
|
5408
5540
|
const built = counts.get(member.member) ?? 0;
|
|
5409
5541
|
const other = !member.self && !member.owner;
|
|
5542
|
+
const where = !member.self && member.online ? together.others().find((peer) => peer.member === member.member) : undefined;
|
|
5410
5543
|
return /* @__PURE__ */ React.createElement("div", {
|
|
5411
5544
|
key: member.member,
|
|
5412
5545
|
className: "tep-member"
|
|
@@ -5428,7 +5561,11 @@ function EarthPeople({ ui, session, manage, words: w, shot, onClose }) {
|
|
|
5428
5561
|
className: "tep-tag"
|
|
5429
5562
|
}, w.lookOnly)), built > 0 && /* @__PURE__ */ React.createElement("span", {
|
|
5430
5563
|
className: "tep-count"
|
|
5431
|
-
}, EarthWords.format(w.builtCount, { count: built }))
|
|
5564
|
+
}, EarthWords.format(w.builtCount, { count: built })), where && onMeet && /* @__PURE__ */ React.createElement("button", {
|
|
5565
|
+
type: "button",
|
|
5566
|
+
className: "tep-small",
|
|
5567
|
+
onClick: () => onMeet(where)
|
|
5568
|
+
}, w.meet)), manage && other && /* @__PURE__ */ React.createElement("div", {
|
|
5432
5569
|
className: "tep-actions"
|
|
5433
5570
|
}, owner && /* @__PURE__ */ React.createElement("button", {
|
|
5434
5571
|
type: "button",
|
|
@@ -7538,6 +7675,65 @@ var EarthGen;
|
|
|
7538
7675
|
}
|
|
7539
7676
|
})(EarthGen ||= {});
|
|
7540
7677
|
|
|
7678
|
+
// web-src/earth-meet.ts
|
|
7679
|
+
var AIR = 3;
|
|
7680
|
+
var DEPTH = 64;
|
|
7681
|
+
var SIDES = [
|
|
7682
|
+
[1, 0],
|
|
7683
|
+
[-1, 0],
|
|
7684
|
+
[0, 1],
|
|
7685
|
+
[0, -1]
|
|
7686
|
+
];
|
|
7687
|
+
var EarthMeet;
|
|
7688
|
+
((EarthMeet) => {
|
|
7689
|
+
function beside(at, solid) {
|
|
7690
|
+
const x = Math.floor(at.x);
|
|
7691
|
+
const z = Math.floor(at.z);
|
|
7692
|
+
let floor = -1;
|
|
7693
|
+
for (let y = Math.floor(at.y - 0.5);y >= Math.max(0, Math.floor(at.y) - DEPTH); y--) {
|
|
7694
|
+
if (solid(x, y, z)) {
|
|
7695
|
+
floor = y;
|
|
7696
|
+
break;
|
|
7697
|
+
}
|
|
7698
|
+
}
|
|
7699
|
+
if (floor < 0 || at.y - (floor + 1) > AIR) {
|
|
7700
|
+
return { x: x + 1.5, y: at.y, z: z + 0.5, flying: true };
|
|
7701
|
+
}
|
|
7702
|
+
for (const [dx, dz] of SIDES) {
|
|
7703
|
+
if (solid(x + dx, floor, z + dz) && !solid(x + dx, floor + 1, z + dz) && !solid(x + dx, floor + 2, z + dz)) {
|
|
7704
|
+
return { x: x + dx + 0.5, y: floor + 1.01, z: z + dz + 0.5, flying: false };
|
|
7705
|
+
}
|
|
7706
|
+
}
|
|
7707
|
+
return { x: x + 0.5, y: floor + 1.01, z: z + 0.5, flying: false };
|
|
7708
|
+
}
|
|
7709
|
+
EarthMeet.beside = beside;
|
|
7710
|
+
})(EarthMeet ||= {});
|
|
7711
|
+
|
|
7712
|
+
class EarthTrip {
|
|
7713
|
+
landing;
|
|
7714
|
+
get going() {
|
|
7715
|
+
return this.landing !== undefined;
|
|
7716
|
+
}
|
|
7717
|
+
stop() {
|
|
7718
|
+
this.landing = undefined;
|
|
7719
|
+
}
|
|
7720
|
+
to(body, x, z, ground, high) {
|
|
7721
|
+
Object.assign(body, { x: Math.floor(x) + 0.5, y: ground + (high || 40), z: Math.floor(z) + 0.5, vx: 0, vy: 0, vz: 0, flying: true });
|
|
7722
|
+
this.landing = high ? undefined : "ground";
|
|
7723
|
+
}
|
|
7724
|
+
meet(body, at) {
|
|
7725
|
+
Object.assign(body, { x: Math.floor(at.x) + 0.5, y: at.y + 0.2, z: Math.floor(at.z) + 0.5, vx: 0, vy: 0, vz: 0, flying: true });
|
|
7726
|
+
this.landing = { x: at.x, y: at.y, z: at.z };
|
|
7727
|
+
}
|
|
7728
|
+
land(body, top, solid) {
|
|
7729
|
+
if (!this.landing || top === undefined) {
|
|
7730
|
+
return;
|
|
7731
|
+
}
|
|
7732
|
+
Object.assign(body, this.landing === "ground" ? { y: top + 1.01, flying: false } : EarthMeet.beside(this.landing, solid), { vy: 0 });
|
|
7733
|
+
this.landing = undefined;
|
|
7734
|
+
}
|
|
7735
|
+
}
|
|
7736
|
+
|
|
7541
7737
|
// web-src/earth-merge.ts
|
|
7542
7738
|
var EarthMerge;
|
|
7543
7739
|
((EarthMerge) => {
|
|
@@ -8468,7 +8664,8 @@ class EarthFall {
|
|
|
8468
8664
|
// web-src/earth-sky.ts
|
|
8469
8665
|
var DAY2 = { sky: 14541536, zenith: 6987732, sun: [1, 1, 1], light: [1, 0.94, 0.82], glow: [0.64, 0.7, 0.8] };
|
|
8470
8666
|
var DUSK = { sky: 16109471, zenith: 9084108, sun: [1, 0.86, 0.74], light: [1, 0.78, 0.52], glow: [1.2, 1.05, 0.8] };
|
|
8471
|
-
var NIGHT = { sky:
|
|
8667
|
+
var NIGHT = { sky: 2240602, zenith: 660528, sun: [0.45, 0.5, 0.7], light: [0.6, 0.7, 1], glow: [1.6, 1.32, 0.78] };
|
|
8668
|
+
var MOONLIT = [0.62, 0.7, 0.95];
|
|
8472
8669
|
var GREY = [0.64, 0.66, 0.69];
|
|
8473
8670
|
var CLOUDS = 1024;
|
|
8474
8671
|
var LOOK2 = {
|
|
@@ -8501,6 +8698,7 @@ class EarthSky {
|
|
|
8501
8698
|
hemisphere;
|
|
8502
8699
|
zenith;
|
|
8503
8700
|
light;
|
|
8701
|
+
moonlit;
|
|
8504
8702
|
star;
|
|
8505
8703
|
fall;
|
|
8506
8704
|
weather;
|
|
@@ -8517,6 +8715,7 @@ class EarthSky {
|
|
|
8517
8715
|
this.sky = new THREE.Color(DAY2.sky);
|
|
8518
8716
|
this.zenith = new THREE.Color(DAY2.zenith);
|
|
8519
8717
|
this.light = new THREE.Color(1, 1, 1);
|
|
8718
|
+
this.moonlit = new THREE.Color;
|
|
8520
8719
|
scene.background = this.sky;
|
|
8521
8720
|
scene.fog = new THREE.Fog(this.sky, far * 0.55, far);
|
|
8522
8721
|
this.canvas = document.createElement("canvas");
|
|
@@ -8561,8 +8760,8 @@ class EarthSky {
|
|
|
8561
8760
|
const dusk = pick(DUSK);
|
|
8562
8761
|
return night.map((n, i) => (n + (noon[i] - n) * day) * (1 - warm) + dusk[i] * warm);
|
|
8563
8762
|
};
|
|
8564
|
-
const rgb = (
|
|
8565
|
-
const c = new this.THREE.Color(
|
|
8763
|
+
const rgb = (hex2) => {
|
|
8764
|
+
const c = new this.THREE.Color(hex2);
|
|
8566
8765
|
return [c.r, c.g, c.b];
|
|
8567
8766
|
};
|
|
8568
8767
|
if (weather?.kind === "storm" && this.flash <= 0 && Math.random() < seconds / 9) {
|
|
@@ -8588,9 +8787,11 @@ class EarthSky {
|
|
|
8588
8787
|
fog.near = Math.hypot(far * look.fog * (1 - 0.5 * warm), above);
|
|
8589
8788
|
fog.far = Math.hypot(far * (look.fog < 0.2 ? 0.45 : 1), above);
|
|
8590
8789
|
this.hemisphere.color.copy(this.zenith).lerp(this.sky, 0.5 + 0.3 * warm);
|
|
8591
|
-
this.
|
|
8790
|
+
this.moonlit.setRGB(MOONLIT[0], MOONLIT[1], MOONLIT[2]);
|
|
8791
|
+
this.hemisphere.color.lerp(this.moonlit, 1 - day);
|
|
8792
|
+
this.hemisphere.intensity = (0.6 + 0.7 * day + 1.4 * warm) * dim + look.grey * 0.5 * day + 0.35 * (1 - day);
|
|
8592
8793
|
const direction = up ? place : { x: -place.x, y: -place.y, z: -place.z };
|
|
8593
|
-
const shine = up ? (1.3 + 1.5 * low) * (1 - look.grey * 0.85) : 0.
|
|
8794
|
+
const shine = up ? (1.3 + 1.5 * low) * (1 - look.grey * 0.85) : (0.3 + 0.6 * low) * (1 - look.grey * 0.6);
|
|
8594
8795
|
const tone = mix((stop) => stop.light);
|
|
8595
8796
|
this.light.setRGB(tone[0], tone[1], tone[2]);
|
|
8596
8797
|
this.star.update({ x: at.x, y: at.y, z: at.z }, direction, this.light, shine + lit * 2, {
|
|
@@ -8803,7 +9004,7 @@ class EarthWorld {
|
|
|
8803
9004
|
eyes;
|
|
8804
9005
|
far;
|
|
8805
9006
|
speed = 1;
|
|
8806
|
-
|
|
9007
|
+
trip = new EarthTrip;
|
|
8807
9008
|
outline;
|
|
8808
9009
|
origin;
|
|
8809
9010
|
radius;
|
|
@@ -8900,16 +9101,17 @@ class EarthWorld {
|
|
|
8900
9101
|
}
|
|
8901
9102
|
toggleFly() {
|
|
8902
9103
|
Object.assign(this.body, { flying: !this.body.flying, vy: 0 });
|
|
8903
|
-
this.
|
|
9104
|
+
this.trip.stop();
|
|
8904
9105
|
}
|
|
8905
9106
|
setSpeed(step = 1, wrap2 = true) {
|
|
8906
9107
|
this.speed = nextSpeed(this.speed, step, wrap2);
|
|
8907
9108
|
}
|
|
8908
9109
|
teleport(x, z) {
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
9110
|
+
this.trip.to(this.body, x, z, this.plots.groundAt(x, z) ?? SURFACE, this.body.flying ? Math.max(this.above, 8) : 0);
|
|
9111
|
+
}
|
|
9112
|
+
others = () => this.start.link?.others() ?? [];
|
|
9113
|
+
meet(pose) {
|
|
9114
|
+
this.trip.meet(this.body, pose);
|
|
8913
9115
|
}
|
|
8914
9116
|
home() {
|
|
8915
9117
|
if (this.homeAt) {
|
|
@@ -8956,7 +9158,7 @@ class EarthWorld {
|
|
|
8956
9158
|
this.mapAt = now;
|
|
8957
9159
|
const canvas = this.hooks.map();
|
|
8958
9160
|
if (canvas) {
|
|
8959
|
-
EarthMap.draw(canvas, (px, pz) => this.plots.raster(px, pz), this.body, this.controls.yaw, 224, this.start.island, this.figures.where(), this.plan?.centre);
|
|
9161
|
+
EarthMap.draw(canvas, (px, pz) => this.plots.raster(px, pz), this.body, this.controls.yaw, 224, this.start.island, this.figures.where(), this.plan?.centre, this.others());
|
|
8960
9162
|
}
|
|
8961
9163
|
}
|
|
8962
9164
|
}
|
|
@@ -9142,14 +9344,9 @@ class EarthWorld {
|
|
|
9142
9344
|
this.eye = Math.max(0, this.eye - seconds * 6);
|
|
9143
9345
|
const ground = this.plots.groundAt(this.body.x, this.body.z) ?? SURFACE;
|
|
9144
9346
|
this.above = this.body.y - ground;
|
|
9145
|
-
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
const top = this.store.top(x, z, blocks.solid);
|
|
9149
|
-
if (top !== undefined && this.meshes.has(VoxelKey.of(Math.floor(x / CHUNK), Math.floor(z / CHUNK)))) {
|
|
9150
|
-
Object.assign(this.body, { y: top + 1.01, vy: 0, flying: false });
|
|
9151
|
-
this.landing = false;
|
|
9152
|
-
}
|
|
9347
|
+
const [x, z] = [Math.floor(this.body.x), Math.floor(this.body.z)];
|
|
9348
|
+
if (this.trip.going && this.meshes.has(VoxelKey.of(Math.floor(x / CHUNK), Math.floor(z / CHUNK)))) {
|
|
9349
|
+
this.trip.land(this.body, this.store.top(x, z, blocks.solid), (bx, by, bz) => blocks.solid[this.store.get(bx, by, bz) ?? 0] === 1);
|
|
9153
9350
|
}
|
|
9154
9351
|
if (this.body.y < -20 || this.above > CEILING) {
|
|
9155
9352
|
Object.assign(this.body, { y: ground + (this.body.y < -20 ? 30 : CEILING), vy: 0 });
|
|
@@ -9525,6 +9722,11 @@ function EarthPlay({ ui, place, save, session, manage, residents, onTalk, office
|
|
|
9525
9722
|
manage,
|
|
9526
9723
|
words: w,
|
|
9527
9724
|
shot,
|
|
9725
|
+
onMeet: (at) => {
|
|
9726
|
+
world.current?.meet(at);
|
|
9727
|
+
setPeople(false);
|
|
9728
|
+
latestContext.current?.element.focus();
|
|
9729
|
+
},
|
|
9528
9730
|
onClose: () => setPeople(false)
|
|
9529
9731
|
}), /* @__PURE__ */ React.createElement("div", {
|
|
9530
9732
|
className: "tew-notes"
|
|
@@ -10670,6 +10872,13 @@ var STYLE = `
|
|
|
10670
10872
|
.tea-dot.tea-visit { background: #f08a24; }
|
|
10671
10873
|
.tea-foot { position: absolute; left: 8px; bottom: 4px; color: rgba(20, 30, 40, 0.65); font-size: calc(10px * var(--ta-font-scale)); pointer-events: none; }
|
|
10672
10874
|
.tea-card ~ .tea-foot { display: none; }
|
|
10875
|
+
.tea-name { position: absolute; left: 0; top: 0; display: block; padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
|
|
10876
|
+
.tea-name > i { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; box-sizing: border-box; border: 2.5px solid #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
|
|
10877
|
+
.tea-name > span { position: absolute; left: 0; bottom: 11px; transform: translateX(-50%); padding: 2px 8px; border-radius: 999px; background: rgba(20, 22, 26, 0.72); color: #fff; font-size: calc(12px * min(var(--ta-font-scale, 1), 1.25)); line-height: 18px; white-space: nowrap; }
|
|
10878
|
+
.tea-people { position: absolute; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); width: calc(100% - 32px); transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; pointer-events: none; }
|
|
10879
|
+
.tea-people .tea-person { pointer-events: auto; background: rgba(20, 22, 26, 0.66); font-weight: 500; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
|
|
10880
|
+
.tea-person > i { width: 10px; height: 10px; flex: none; border: 1.5px solid #fff; border-radius: 50%; }
|
|
10881
|
+
.tea-dot.tea-round { border-radius: 50%; }
|
|
10673
10882
|
.tep-choice { align-items: flex-start; }
|
|
10674
10883
|
.tep-choice input { margin-top: 3px; }
|
|
10675
10884
|
.tep-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
|