@adatechnology/game-terrain-three 0.2.0 → 0.3.1
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/dist/chunk-JAVYWW3G.js +134 -0
- package/dist/chunk-JAVYWW3G.js.map +1 -0
- package/dist/index.d.ts +3 -13
- package/dist/index.global.js +58 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +7 -121
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +14 -0
- package/dist/testing.js +11 -0
- package/dist/testing.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// src/test-area/test-module.ts
|
|
2
|
+
import { markKitOrigin } from "@adatechnology/game-contracts";
|
|
3
|
+
|
|
4
|
+
// src/test-area/locale.ts
|
|
5
|
+
var PROFILE_NAMES = {
|
|
6
|
+
en: { lawn: "Lawn", dirt: "Dirt", sand: "Sand", road: "Asphalt road", concrete_slab: "Concrete slab", suspended_slab: "Slab over a void", tile_floor: "Tile floor", wood_floor: "Wood floor", stone_paving: "Stone paving" },
|
|
7
|
+
"pt-BR": { lawn: "Grama", dirt: "Terra", sand: "Areia", road: "Asfalto", concrete_slab: "Laje de concreto", suspended_slab: "Laje sobre v\xE3o", tile_floor: "Piso cer\xE2mico", wood_floor: "Assoalho", stone_paving: "Cal\xE7amento de pedra" }
|
|
8
|
+
};
|
|
9
|
+
function terrainProfileName(profileId, localeId) {
|
|
10
|
+
return (PROFILE_NAMES[localeId] ?? PROFILE_NAMES.en)[profileId] ?? profileId;
|
|
11
|
+
}
|
|
12
|
+
var LOCALES = {
|
|
13
|
+
en: {
|
|
14
|
+
name: "Terrain",
|
|
15
|
+
group: "Terrain",
|
|
16
|
+
weight: "Concrete block (60 kg)",
|
|
17
|
+
surfaces: { dirt: "Dirt", lawn: "Lawn", sand: "Sand", road: "Asphalt", concrete_slab: "Concrete slab", suspended_slab: "Slab over a void", wood_floor: "Wood floor", tile_floor: "Tile", stone_paving: "Stone paving" }
|
|
18
|
+
},
|
|
19
|
+
"pt-BR": {
|
|
20
|
+
name: "Terreno",
|
|
21
|
+
group: "Terreno",
|
|
22
|
+
weight: "Bloco de concreto (60 kg)",
|
|
23
|
+
surfaces: { dirt: "Terra", lawn: "Grama", sand: "Areia", road: "Asfalto", concrete_slab: "Laje de concreto", suspended_slab: "Laje sobre v\xE3o", wood_floor: "Assoalho", tile_floor: "Cer\xE2mica", stone_paving: "Pedra" }
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var locale = (id) => LOCALES[id] ?? LOCALES.en;
|
|
27
|
+
|
|
28
|
+
// src/test-area/test-module.ts
|
|
29
|
+
var TERRAIN_STRIPS = ["dirt", "lawn", "sand", "road", "concrete_slab", "suspended_slab", "wood_floor", "tile_floor", "stone_paving"];
|
|
30
|
+
var STRIP_WIDTH = 3;
|
|
31
|
+
var STRIP_Z0 = 4;
|
|
32
|
+
var STRIP_Z1 = 13;
|
|
33
|
+
var stripRect = (index) => {
|
|
34
|
+
const x0 = (index - TERRAIN_STRIPS.length / 2) * STRIP_WIDTH;
|
|
35
|
+
return [x0, STRIP_Z0, x0 + STRIP_WIDTH, STRIP_Z1];
|
|
36
|
+
};
|
|
37
|
+
var TERRAIN_AREA_GROUND = {
|
|
38
|
+
surface: "concrete_slab",
|
|
39
|
+
zones: TERRAIN_STRIPS.map((surface, index) => ({ rect: stripRect(index), surface }))
|
|
40
|
+
};
|
|
41
|
+
var WEIGHT_SIDE = 0.32;
|
|
42
|
+
var WEIGHT_HEIGHT = 4;
|
|
43
|
+
var LABEL_Y = 0.02;
|
|
44
|
+
var LABEL_WIDTH = 2.6;
|
|
45
|
+
var LABEL_HEIGHT = 0.5;
|
|
46
|
+
function weightSpec() {
|
|
47
|
+
return { name: "Weight", parts: [{ id: "block", material: "concrete", shape: { kind: "box", size: [WEIGHT_SIDE, WEIGHT_SIDE, WEIGHT_SIDE] }, position: [0, WEIGHT_SIDE / 2, 0] }], joints: [] };
|
|
48
|
+
}
|
|
49
|
+
function buildWeight(THREE) {
|
|
50
|
+
const mesh = new THREE.Mesh(new THREE.BoxGeometry(WEIGHT_SIDE, WEIGHT_SIDE, WEIGHT_SIDE), new THREE.MeshStandardMaterial({ color: 11842734, roughness: 0.9 }));
|
|
51
|
+
mesh.name = "block";
|
|
52
|
+
mesh.position.y = WEIGHT_SIDE / 2;
|
|
53
|
+
mesh.castShadow = true;
|
|
54
|
+
const root = markKitOrigin(new THREE.Group(), { owner: "game-terrain-three", kind: "item" });
|
|
55
|
+
root.add(mesh);
|
|
56
|
+
return root;
|
|
57
|
+
}
|
|
58
|
+
function buildLabel(THREE, text, x) {
|
|
59
|
+
if (typeof document === "undefined") return null;
|
|
60
|
+
const canvas = document.createElement("canvas");
|
|
61
|
+
canvas.width = 512;
|
|
62
|
+
canvas.height = 96;
|
|
63
|
+
const context = canvas.getContext("2d");
|
|
64
|
+
if (!context) return null;
|
|
65
|
+
context.fillStyle = "rgba(0,0,0,0.55)";
|
|
66
|
+
context.fillRect(0, 0, 512, 96);
|
|
67
|
+
context.fillStyle = "#fff";
|
|
68
|
+
context.font = "bold 54px sans-serif";
|
|
69
|
+
context.textAlign = "center";
|
|
70
|
+
context.textBaseline = "middle";
|
|
71
|
+
context.fillText(text, 256, 50);
|
|
72
|
+
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(LABEL_WIDTH, LABEL_HEIGHT), new THREE.MeshBasicMaterial({ map: new THREE.CanvasTexture(canvas), transparent: true }));
|
|
73
|
+
markKitOrigin(mesh, { owner: "game-terrain-three", kind: "room" });
|
|
74
|
+
mesh.rotation.set(-Math.PI / 2, 0, Math.PI);
|
|
75
|
+
mesh.position.set(x, LABEL_Y, STRIP_Z0 - LABEL_HEIGHT);
|
|
76
|
+
return mesh;
|
|
77
|
+
}
|
|
78
|
+
function createTerrainTestModule(options = {}) {
|
|
79
|
+
let labels = [];
|
|
80
|
+
const text = locale(options.locale ?? "en");
|
|
81
|
+
return {
|
|
82
|
+
id: "terrain",
|
|
83
|
+
name: text.name,
|
|
84
|
+
group: text.group,
|
|
85
|
+
ground: TERRAIN_AREA_GROUND,
|
|
86
|
+
items() {
|
|
87
|
+
return [{ id: "terrain_weight", name: text.weight, build: (THREE) => buildWeight(THREE), spec: weightSpec, movable: true }];
|
|
88
|
+
},
|
|
89
|
+
area() {
|
|
90
|
+
for (const label of labels) label.visible = true;
|
|
91
|
+
return {
|
|
92
|
+
placements: TERRAIN_STRIPS.map((_, index) => {
|
|
93
|
+
const [x0] = stripRect(index);
|
|
94
|
+
return { item: "terrain_weight", position: [x0 + STRIP_WIDTH / 2, WEIGHT_HEIGHT, STRIP_Z1 - 1.2] };
|
|
95
|
+
}),
|
|
96
|
+
view: { eye: [0, 1.7, 1.5], target: [0, 0, 8] }
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
attach(host) {
|
|
100
|
+
const THREE = host.THREE;
|
|
101
|
+
const scene = host.scene;
|
|
102
|
+
labels = TERRAIN_STRIPS.flatMap((surface, index) => {
|
|
103
|
+
const [x0] = stripRect(index);
|
|
104
|
+
const label = buildLabel(THREE, text.surfaces[surface], x0 + STRIP_WIDTH / 2);
|
|
105
|
+
if (!label) return [];
|
|
106
|
+
label.visible = false;
|
|
107
|
+
scene.add(label);
|
|
108
|
+
return [label];
|
|
109
|
+
});
|
|
110
|
+
const stop = host.onClear?.(() => {
|
|
111
|
+
for (const label of labels) label.visible = false;
|
|
112
|
+
});
|
|
113
|
+
return () => {
|
|
114
|
+
stop?.();
|
|
115
|
+
for (const label of labels) {
|
|
116
|
+
label.removeFromParent();
|
|
117
|
+
const mesh = label;
|
|
118
|
+
mesh.geometry.dispose();
|
|
119
|
+
mesh.material.map?.dispose();
|
|
120
|
+
mesh.material.dispose();
|
|
121
|
+
}
|
|
122
|
+
labels = [];
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
terrainProfileName,
|
|
130
|
+
TERRAIN_STRIPS,
|
|
131
|
+
TERRAIN_AREA_GROUND,
|
|
132
|
+
createTerrainTestModule
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=chunk-JAVYWW3G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/test-area/test-module.ts","../src/test-area/locale.ts"],"sourcesContent":["import type * as THREE_NS from 'three'\nimport { markKitOrigin } from '@adatechnology/game-contracts'\nimport type { DestructibleSpec, GroundLayout, ModuleArea, ModuleHost, TestableItem, TestableModule } from '@adatechnology/game-contracts'\nimport { locale as localeTable } from './locale'\n\ntype ThreeLib = typeof THREE_NS\n\n/** The strips of the area, side by side, one of each ground. */\nexport const TERRAIN_STRIPS = ['dirt', 'lawn', 'sand', 'road', 'concrete_slab', 'suspended_slab', 'wood_floor', 'tile_floor', 'stone_paving'] as const\nconst STRIP_WIDTH = 3\nconst STRIP_Z0 = 4\nconst STRIP_Z1 = 13\nconst stripRect = (index: number): readonly [number, number, number, number] => {\n const x0 = (index - TERRAIN_STRIPS.length / 2) * STRIP_WIDTH\n return [x0, STRIP_Z0, x0 + STRIP_WIDTH, STRIP_Z1]\n}\nexport const TERRAIN_AREA_GROUND: GroundLayout = {\n surface: 'concrete_slab',\n zones: TERRAIN_STRIPS.map((surface, index) => ({ rect: stripRect(index), surface })),\n}\n\nconst WEIGHT_SIDE = 0.32\nconst WEIGHT_HEIGHT = 4\nconst LABEL_Y = 0.02\nconst LABEL_WIDTH = 2.6\nconst LABEL_HEIGHT = 0.5\n\nfunction weightSpec(): DestructibleSpec {\n return { name: 'Weight', parts: [{ id: 'block', material: 'concrete', shape: { kind: 'box', size: [WEIGHT_SIDE, WEIGHT_SIDE, WEIGHT_SIDE] }, position: [0, WEIGHT_SIDE / 2, 0] }], joints: [] }\n}\n\nfunction buildWeight(THREE: ThreeLib): THREE_NS.Object3D {\n const mesh = new THREE.Mesh(new THREE.BoxGeometry(WEIGHT_SIDE, WEIGHT_SIDE, WEIGHT_SIDE), new THREE.MeshStandardMaterial({ color: 0xb4b4ae, roughness: 0.9 }))\n mesh.name = 'block'\n mesh.position.y = WEIGHT_SIDE / 2\n mesh.castShadow = true\n const root = markKitOrigin(new THREE.Group(), { owner: 'game-terrain-three', kind: 'item' })\n root.add(mesh)\n return root\n}\n\nfunction buildLabel(THREE: ThreeLib, text: string, x: number): THREE_NS.Object3D | null {\n if (typeof document === 'undefined') return null\n const canvas = document.createElement('canvas')\n canvas.width = 512\n canvas.height = 96\n const context = canvas.getContext('2d')\n if (!context) return null\n context.fillStyle = 'rgba(0,0,0,0.55)'\n context.fillRect(0, 0, 512, 96)\n context.fillStyle = '#fff'\n context.font = 'bold 54px sans-serif'\n context.textAlign = 'center'\n context.textBaseline = 'middle'\n context.fillText(text, 256, 50)\n const mesh = new THREE.Mesh(new THREE.PlaneGeometry(LABEL_WIDTH, LABEL_HEIGHT), new THREE.MeshBasicMaterial({ map: new THREE.CanvasTexture(canvas), transparent: true }))\n // read from the start of the area, looking along +z\n markKitOrigin(mesh, { owner: 'game-terrain-three', kind: 'room' })\n mesh.rotation.set(-Math.PI / 2, 0, Math.PI)\n mesh.position.set(x, LABEL_Y, STRIP_Z0 - LABEL_HEIGHT)\n return mesh\n}\n\n/**\n * The ground bench: a strip of each surface side by side to shoot, blow up, burn and drop weights on. Opening the area lays the strips (`ground`) and drops a concrete block\n * on each from four metres.\n */\nexport function createTerrainTestModule(options: { readonly locale?: string } = {}): TestableModule {\n let labels: THREE_NS.Object3D[] = []\n const text = localeTable(options.locale ?? 'en')\n return {\n id: 'terrain',\n name: text.name,\n group: text.group,\n ground: TERRAIN_AREA_GROUND,\n items(): TestableItem[] {\n return [{ id: 'terrain_weight', name: text.weight, build: (THREE) => buildWeight(THREE as ThreeLib), spec: weightSpec, movable: true }]\n },\n area(): ModuleArea {\n for (const label of labels) label.visible = true\n return {\n placements: TERRAIN_STRIPS.map((_, index) => {\n const [x0] = stripRect(index)\n return { item: 'terrain_weight', position: [x0 + STRIP_WIDTH / 2, WEIGHT_HEIGHT, STRIP_Z1 - 1.2] }\n }),\n view: { eye: [0, 1.7, 1.5], target: [0, 0, 8] },\n }\n },\n attach(host: ModuleHost): () => void {\n const THREE = host.THREE as ThreeLib\n const scene = host.scene as THREE_NS.Scene\n labels = TERRAIN_STRIPS.flatMap((surface, index) => {\n const [x0] = stripRect(index)\n const label = buildLabel(THREE, text.surfaces[surface], x0 + STRIP_WIDTH / 2)\n if (!label) return []\n label.visible = false\n scene.add(label)\n return [label]\n })\n const stop = host.onClear?.(() => {\n for (const label of labels) label.visible = false\n })\n return () => {\n stop?.()\n // each label is built for this attach (its own plane, material and canvas texture): freed when the area goes\n for (const label of labels) {\n label.removeFromParent()\n const mesh = label as THREE_NS.Mesh<THREE_NS.BufferGeometry, THREE_NS.MeshBasicMaterial>\n mesh.geometry.dispose()\n mesh.material.map?.dispose()\n mesh.material.dispose()\n }\n labels = []\n }\n },\n }\n}\n","import type { TERRAIN_STRIPS } from './test-module'\n\n/** The ground profiles of the catalogue (`TERRAIN_PROFILES` of game-terrain) by name, for a HUD that says what the floor under the aim is. */\nconst PROFILE_NAMES: Record<string, Record<string, string>> = {\n en: { lawn: 'Lawn', dirt: 'Dirt', sand: 'Sand', road: 'Asphalt road', concrete_slab: 'Concrete slab', suspended_slab: 'Slab over a void', tile_floor: 'Tile floor', wood_floor: 'Wood floor', stone_paving: 'Stone paving' },\n 'pt-BR': { lawn: 'Grama', dirt: 'Terra', sand: 'Areia', road: 'Asfalto', concrete_slab: 'Laje de concreto', suspended_slab: 'Laje sobre vão', tile_floor: 'Piso cerâmico', wood_floor: 'Assoalho', stone_paving: 'Calçamento de pedra' },\n}\n\n/** The name of a ground profile in the locale (`en` when the locale is unknown); a profile a game added without a name answers its id. */\nexport function terrainProfileName(profileId: string, localeId: string): string {\n return (PROFILE_NAMES[localeId] ?? PROFILE_NAMES.en!)[profileId] ?? profileId\n}\n\ninterface TerrainText {\n readonly name: string\n readonly group: string\n readonly weight: string\n readonly surfaces: Record<(typeof TERRAIN_STRIPS)[number], string>\n}\n\nconst LOCALES: Record<string, TerrainText> = {\n en: {\n name: 'Terrain',\n group: 'Terrain',\n weight: 'Concrete block (60 kg)',\n surfaces: { dirt: 'Dirt', lawn: 'Lawn', sand: 'Sand', road: 'Asphalt', concrete_slab: 'Concrete slab', suspended_slab: 'Slab over a void', wood_floor: 'Wood floor', tile_floor: 'Tile', stone_paving: 'Stone paving' },\n },\n 'pt-BR': {\n name: 'Terreno',\n group: 'Terreno',\n weight: 'Bloco de concreto (60 kg)',\n surfaces: { dirt: 'Terra', lawn: 'Grama', sand: 'Areia', road: 'Asfalto', concrete_slab: 'Laje de concreto', suspended_slab: 'Laje sobre vão', wood_floor: 'Assoalho', tile_floor: 'Cerâmica', stone_paving: 'Pedra' },\n },\n}\n\nexport const locale = (id: string): TerrainText => LOCALES[id] ?? LOCALES.en!\n"],"mappings":";AACA,SAAS,qBAAqB;;;ACE9B,IAAM,gBAAwD;AAAA,EAC5D,IAAI,EAAE,MAAM,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,gBAAgB,eAAe,iBAAiB,gBAAgB,oBAAoB,YAAY,cAAc,YAAY,cAAc,cAAc,eAAe;AAAA,EAC3N,SAAS,EAAE,MAAM,SAAS,MAAM,SAAS,MAAM,SAAS,MAAM,WAAW,eAAe,oBAAoB,gBAAgB,qBAAkB,YAAY,oBAAiB,YAAY,YAAY,cAAc,yBAAsB;AACzO;AAGO,SAAS,mBAAmB,WAAmB,UAA0B;AAC9E,UAAQ,cAAc,QAAQ,KAAK,cAAc,IAAK,SAAS,KAAK;AACtE;AASA,IAAM,UAAuC;AAAA,EAC3C,IAAI;AAAA,IACF,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU,EAAE,MAAM,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,WAAW,eAAe,iBAAiB,gBAAgB,oBAAoB,YAAY,cAAc,YAAY,QAA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2
|
import { Terrain } from '@adatechnology/game-terrain';
|
|
3
|
-
|
|
3
|
+
export { TERRAIN_AREA_GROUND, TERRAIN_STRIPS, createTerrainTestModule } from './testing.js';
|
|
4
|
+
import '@adatechnology/game-contracts';
|
|
4
5
|
|
|
5
6
|
type ThreeLib$1 = typeof THREE_NS;
|
|
6
7
|
interface TerrainRendererOptions {
|
|
@@ -37,18 +38,7 @@ type ThreeLib = typeof THREE_NS;
|
|
|
37
38
|
/** The ground's material: the colour of what is exposed comes per vertex, flat so that the edge between two materials stays sharp, its pattern (blades of grass, grout, planks) is drawn per pixel from the world position so that it never tiles or stretches. */
|
|
38
39
|
declare function createSurfaceMaterial(THREE: ThreeLib): THREE_NS.MeshStandardMaterial;
|
|
39
40
|
|
|
40
|
-
/** The strips of the area, side by side, one of each ground. */
|
|
41
|
-
declare const TERRAIN_STRIPS: readonly ["dirt", "lawn", "sand", "road", "concrete_slab", "suspended_slab", "wood_floor", "tile_floor", "stone_paving"];
|
|
42
|
-
declare const TERRAIN_AREA_GROUND: GroundLayout;
|
|
43
|
-
/**
|
|
44
|
-
* The ground bench: a strip of each surface side by side to shoot, blow up, burn and drop weights on. Opening the area lays the strips (`ground`) and drops a concrete block
|
|
45
|
-
* on each from four metres.
|
|
46
|
-
*/
|
|
47
|
-
declare function createTerrainTestModule(options?: {
|
|
48
|
-
readonly locale?: string;
|
|
49
|
-
}): TestableModule;
|
|
50
|
-
|
|
51
41
|
/** The name of a ground profile in the locale (`en` when the locale is unknown); a profile a game added without a name answers its id. */
|
|
52
42
|
declare function terrainProfileName(profileId: string, localeId: string): string;
|
|
53
43
|
|
|
54
|
-
export {
|
|
44
|
+
export { type TerrainRenderer, type TerrainRendererOptions, createSurfaceMaterial, createTerrainRenderer, terrainProfileName };
|
package/dist/index.global.js
CHANGED
|
@@ -30,6 +30,19 @@ var GameTerrainThree = (() => {
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
// ../game-contracts/dist/index.js
|
|
33
|
+
var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
|
|
34
|
+
var DEFERRED_QUEUE_ID = {
|
|
35
|
+
DESTRUCTION_EVENTS: "destruction.events",
|
|
36
|
+
BREACH_PAINT: "floorplan.breach-paint",
|
|
37
|
+
AUDIO_VOICES: "audio.voices",
|
|
38
|
+
VEHICLE_CREASE: "vehicles.crease"
|
|
39
|
+
};
|
|
40
|
+
var DEFERRED_PRIORITY = {
|
|
41
|
+
[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
|
|
42
|
+
[DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present" },
|
|
43
|
+
[DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
|
|
44
|
+
[DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" }
|
|
45
|
+
};
|
|
33
46
|
var KIT_ORIGIN_KEY = "kitOrigin";
|
|
34
47
|
function markKitOrigin(object, origin) {
|
|
35
48
|
const node = object;
|
|
@@ -37,6 +50,42 @@ var GameTerrainThree = (() => {
|
|
|
37
50
|
node.userData[KIT_ORIGIN_KEY] = { ...origin };
|
|
38
51
|
return object;
|
|
39
52
|
}
|
|
53
|
+
var SURFACE_IDS = ["concrete", "asphalt", "wood", "tile", "dirt", "grass", "gravel", "sand", "metal", "water", "glass", "carpet"];
|
|
54
|
+
var GAIT_IDS = ["walk", "run"];
|
|
55
|
+
var LANDING_IDS = ["light", "heavy"];
|
|
56
|
+
var BODY_SOUND_IDS = [
|
|
57
|
+
"jump",
|
|
58
|
+
"cloth_rustle",
|
|
59
|
+
"body_fall",
|
|
60
|
+
"fall_damage",
|
|
61
|
+
"player_hurt",
|
|
62
|
+
"player_breath_run",
|
|
63
|
+
"player_death",
|
|
64
|
+
"bite",
|
|
65
|
+
"grab",
|
|
66
|
+
"punch_swing",
|
|
67
|
+
"punch_hit_body",
|
|
68
|
+
"punch_hit_face",
|
|
69
|
+
"punch_hit_object",
|
|
70
|
+
"kick_swing",
|
|
71
|
+
"kick_hit",
|
|
72
|
+
"kick_hit_object",
|
|
73
|
+
"shove_two_hands",
|
|
74
|
+
"knife_swing",
|
|
75
|
+
"knife_stab",
|
|
76
|
+
"knife_slash",
|
|
77
|
+
"knife_hit_object",
|
|
78
|
+
"blunt_swing",
|
|
79
|
+
"blunt_hit",
|
|
80
|
+
"blunt_hit_object",
|
|
81
|
+
"axe_swing",
|
|
82
|
+
"axe_chop",
|
|
83
|
+
"axe_hit_object"
|
|
84
|
+
];
|
|
85
|
+
var footstepSoundId = (surface, gait) => `footstep_${surface}_${gait}`;
|
|
86
|
+
var FOOTSTEP_SOUND_IDS = SURFACE_IDS.flatMap((surface) => GAIT_IDS.map((gait) => footstepSoundId(surface, gait)));
|
|
87
|
+
var LAND_SOUND_IDS = SURFACE_IDS.flatMap((surface) => LANDING_IDS.map((landing) => `land_${surface}_${landing}`));
|
|
88
|
+
var BODY_FOLEY_IDS = [...FOOTSTEP_SOUND_IDS, ...LAND_SOUND_IDS, ...BODY_SOUND_IDS];
|
|
40
89
|
|
|
41
90
|
// ../game-terrain/dist/index.js
|
|
42
91
|
function createRandom(seed) {
|
|
@@ -782,7 +831,7 @@ ${SURFACE_GLSL}`).replace("#include <color_fragment>", "#include <color_fragment
|
|
|
782
831
|
};
|
|
783
832
|
}
|
|
784
833
|
|
|
785
|
-
// src/locale.ts
|
|
834
|
+
// src/test-area/locale.ts
|
|
786
835
|
var PROFILE_NAMES = {
|
|
787
836
|
en: { lawn: "Lawn", dirt: "Dirt", sand: "Sand", road: "Asphalt road", concrete_slab: "Concrete slab", suspended_slab: "Slab over a void", tile_floor: "Tile floor", wood_floor: "Wood floor", stone_paving: "Stone paving" },
|
|
788
837
|
"pt-BR": { lawn: "Grama", dirt: "Terra", sand: "Areia", road: "Asfalto", concrete_slab: "Laje de concreto", suspended_slab: "Laje sobre v\xE3o", tile_floor: "Piso cer\xE2mico", wood_floor: "Assoalho", stone_paving: "Cal\xE7amento de pedra" }
|
|
@@ -806,7 +855,7 @@ ${SURFACE_GLSL}`).replace("#include <color_fragment>", "#include <color_fragment
|
|
|
806
855
|
};
|
|
807
856
|
var locale = (id) => LOCALES[id] ?? LOCALES.en;
|
|
808
857
|
|
|
809
|
-
// src/test-module.ts
|
|
858
|
+
// src/test-area/test-module.ts
|
|
810
859
|
var TERRAIN_STRIPS = ["dirt", "lawn", "sand", "road", "concrete_slab", "suspended_slab", "wood_floor", "tile_floor", "stone_paving"];
|
|
811
860
|
var STRIP_WIDTH = 3;
|
|
812
861
|
var STRIP_Z0 = 4;
|
|
@@ -893,7 +942,13 @@ ${SURFACE_GLSL}`).replace("#include <color_fragment>", "#include <color_fragment
|
|
|
893
942
|
});
|
|
894
943
|
return () => {
|
|
895
944
|
stop?.();
|
|
896
|
-
for (const label of labels)
|
|
945
|
+
for (const label of labels) {
|
|
946
|
+
label.removeFromParent();
|
|
947
|
+
const mesh = label;
|
|
948
|
+
mesh.geometry.dispose();
|
|
949
|
+
mesh.material.map?.dispose();
|
|
950
|
+
mesh.material.dispose();
|
|
951
|
+
}
|
|
897
952
|
labels = [];
|
|
898
953
|
};
|
|
899
954
|
}
|