evomeme 0.1.7 → 0.1.9-beta.14
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/canvas-public/app.js +8517 -1692
- package/dist/canvas-public/assets/presets/catalog.json +47 -0
- package/dist/canvas-public/assets/presets/tiles/A_01_CaoDi.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_02_ShaMo.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_03_TianKong.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_04_ShuiBo.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_05_HaiMian.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_06_MuDiBan.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_07_ShiZhuan.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_08_AnRongYan.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_09_QingTaiShi.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_10_ShenHai.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_11_HuiYanShi.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_12_HongTu.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_13_GengDi.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_14_HuoShanYan.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_15_NiTu.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_16_HuangSha.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_17_CongLin.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_18_ZiYanShi.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_19_MoGuTu.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_20_HuaDian.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_21_HaiLang.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_22_GanTu.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_23_QingTaiShiBan.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_24_XingKong.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_25_MoFaFuWen.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_26_ShiTuYeDi.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_27_LanZhuan.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_28_HongZhuan.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_29_YueQiu.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_30_JinShuGe.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_31_JinShuJingGai.png +0 -0
- package/dist/canvas-public/assets/presets/tiles/A_32_ShuZiChuang.png +0 -0
- package/dist/canvas-public/color-key-worker.js +280 -0
- package/dist/canvas-public/image-canvas-size-editor.js +254 -0
- package/dist/canvas-public/index.html +226 -119
- package/dist/canvas-public/perfect-pixel-worker.js +499 -0
- package/dist/canvas-public/smart-split.js +1 -1
- package/dist/canvas-public/styles.css +3902 -1225
- package/dist/canvas-public/tile-map-editor.js +2120 -0
- package/dist/canvas-public/ui-controls.js +95 -0
- package/dist/canvas-public/vendor/pixi-tilemap.js +126 -0
- package/dist/canvas-public/vendor/pixi.min.js +2340 -0
- package/dist/index.js +32263 -4187
- package/dist/stage-blender/bake_materials.py +102 -0
- package/dist/stage-blender/export_scene.py +275 -0
- package/dist/stage-blender/preview_camera.py +90 -0
- package/dist/stage-blender/repair_mesh.py +112 -0
- package/dist/stage-public/app.js +759 -0
- package/dist/stage-public/baked/bakePilot.js +44 -0
- package/dist/stage-public/baked/bakedScene.js +129 -0
- package/dist/stage-public/baked/sceneAppearance.js +225 -0
- package/dist/stage-public/baked/sceneCamera.js +45 -0
- package/dist/stage-public/comparison-contract.js +28 -0
- package/dist/stage-public/delivery.html +4 -0
- package/dist/stage-public/delivery.js +17 -0
- package/dist/stage-public/godot/appearance.gd +170 -0
- package/dist/stage-public/godot/preview.gd +79 -0
- package/dist/stage-public/index.html +141 -0
- package/dist/stage-public/review-app.js +289 -0
- package/dist/stage-public/review-runtime.js +63 -0
- package/dist/stage-public/review.css +24 -0
- package/dist/stage-public/review.html +47 -0
- package/dist/stage-public/scene-runtime.js +212 -0
- package/dist/stage-public/sceneContractRuntime.js +235 -0
- package/dist/stage-public/styles.css +328 -0
- package/dist/stage-public/three-appearance.js +104 -0
- package/dist/stage-public/vendor/three170/LICENSE +21 -0
- package/dist/stage-public/vendor/three170/build/three.module.js +54571 -0
- package/dist/stage-public/vendor/three170/examples/jsm/controls/OrbitControls.js +1523 -0
- package/dist/stage-public/vendor/three170/examples/jsm/environments/RoomEnvironment.js +144 -0
- package/dist/stage-public/vendor/three170/examples/jsm/libs/fflate.module.js +2672 -0
- package/dist/stage-public/vendor/three170/examples/jsm/loaders/EXRLoader.js +2563 -0
- package/dist/stage-public/vendor/three170/examples/jsm/loaders/GLTFLoader.js +4727 -0
- package/dist/stage-public/vendor/three170/examples/jsm/utils/BufferGeometryUtils.js +1373 -0
- package/dist/tile-transition-mask.svg +40 -0
- package/package.json +77 -69
- package/skills/evomeme-canvas/SKILL.md +52 -0
- package/skills/evomeme-canvas/agents/openai.yaml +7 -0
- package/skills/evomeme-cover/SKILL.md +1 -1
- package/skills/evomeme-game-maker/SKILL.md +79 -8
- package/skills/game-asset-align/SKILL.md +45 -0
- package/skills/game-asset-align/agents/openai.yaml +8 -0
- package/skills/game-asset-align/references/alignment-contract.md +61 -0
- package/skills/game-asset-align/references/blender-scene-pipeline.md +45 -0
- package/skills/game-asset-align/references/canonical-package.md +26 -0
- package/skills/game-asset-align/references/engine-capabilities.md +14 -0
- package/skills/game-asset-align/references/lightweight-review.md +32 -0
- package/skills/game-asset-align/references/repair-policy.md +30 -0
- package/skills/game-asset-align/references/tool-contract.md +39 -0
- package/skills/game-asset-align/references/visual-review.md +26 -0
- package/skills/game-asset-image-generator/SKILL.md +1 -1
- package/skills/godot-3d-game/SKILL.md +39 -0
- package/skills/godot-3d-game/agents/openai.yaml +8 -0
- package/skills/godot-3d-game/references/alignment-gates.md +26 -0
- package/skills/godot-3d-game/references/appearance-alignment.md +52 -0
- package/skills/godot-3d-game/references/build-and-qa.md +22 -0
- package/skills/godot-3d-game/references/canonical-asset-runtime.md +27 -0
- package/skills/godot-3d-game/references/import-and-wrapper-scenes.md +20 -0
- package/skills/godot-3d-game/references/physics-colliders.md +13 -0
- package/skills/godot-3d-game/references/project-structure.md +22 -0
- package/skills/godot-3d-game/references/skeleton-animation.md +16 -0
- package/skills/threejs-3d-game/SKILL.md +6 -2
- package/skills/threejs-3d-game/references/engine-asset-pipeline.md +52 -15
- package/dist/canvas-public/sequence-sheet.js +0 -59
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--bg: #f4efe6;
|
|
3
|
+
--panel: #faf6ef;
|
|
4
|
+
--line: #d9d0c2;
|
|
5
|
+
--text: #2f2a24;
|
|
6
|
+
--muted: #7a7266;
|
|
7
|
+
--accent: #3a6f8f;
|
|
8
|
+
--accent-2: #5a6b4a;
|
|
9
|
+
--ink: #4a433a;
|
|
10
|
+
--paper: #b7c9d6;
|
|
11
|
+
--danger: #b54a3c;
|
|
12
|
+
--mono: 'IBM Plex Mono', ui-monospace, monospace;
|
|
13
|
+
--sans: 'IBM Plex Sans', system-ui, sans-serif;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
* {
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
html,
|
|
21
|
+
body {
|
|
22
|
+
margin: 0;
|
|
23
|
+
height: 100%;
|
|
24
|
+
background:
|
|
25
|
+
radial-gradient(900px 480px at 18% -8%, #fffdf8 0%, transparent 55%),
|
|
26
|
+
radial-gradient(700px 420px at 90% 110%, #ebe3d4 0%, transparent 50%),
|
|
27
|
+
var(--bg);
|
|
28
|
+
color: var(--text);
|
|
29
|
+
font-family: var(--sans);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.shell {
|
|
33
|
+
display: grid;
|
|
34
|
+
grid-template-columns: 280px 1fr 300px;
|
|
35
|
+
height: 100%;
|
|
36
|
+
min-height: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.rail,
|
|
40
|
+
.inspector {
|
|
41
|
+
background: color-mix(in srgb, var(--panel) 92%, white);
|
|
42
|
+
border-right: 1px solid var(--line);
|
|
43
|
+
padding: 20px 16px;
|
|
44
|
+
overflow: auto;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.inspector {
|
|
48
|
+
border-right: 0;
|
|
49
|
+
border-left: 1px solid var(--line);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.brand h1 {
|
|
53
|
+
margin: 0;
|
|
54
|
+
font-size: 1.35rem;
|
|
55
|
+
letter-spacing: 0.02em;
|
|
56
|
+
color: var(--ink);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.eyebrow {
|
|
60
|
+
margin: 0 0 4px;
|
|
61
|
+
color: var(--accent-2);
|
|
62
|
+
font-size: 0.75rem;
|
|
63
|
+
text-transform: uppercase;
|
|
64
|
+
letter-spacing: 0.14em;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.tagline {
|
|
68
|
+
margin: 8px 0 14px;
|
|
69
|
+
color: var(--muted);
|
|
70
|
+
font-size: 0.85rem;
|
|
71
|
+
line-height: 1.4;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.rail-guide {
|
|
75
|
+
margin: 0 0 14px;
|
|
76
|
+
padding: 12px;
|
|
77
|
+
border: 1px dashed var(--line);
|
|
78
|
+
border-radius: 10px;
|
|
79
|
+
background: #fffdf8;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.rail-guide p {
|
|
83
|
+
margin: 0 0 8px;
|
|
84
|
+
color: var(--muted);
|
|
85
|
+
font-size: 0.82rem;
|
|
86
|
+
line-height: 1.45;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.rail-guide code {
|
|
90
|
+
display: block;
|
|
91
|
+
font-family: var(--mono);
|
|
92
|
+
font-size: 0.75rem;
|
|
93
|
+
color: var(--accent);
|
|
94
|
+
word-break: break-all;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.rail-guide[hidden] {
|
|
98
|
+
display: none;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.list {
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-direction: column;
|
|
104
|
+
gap: 8px;
|
|
105
|
+
margin-top: 14px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.list button {
|
|
109
|
+
text-align: left;
|
|
110
|
+
width: 100%;
|
|
111
|
+
border: 1px solid var(--line);
|
|
112
|
+
background: #fffdf8;
|
|
113
|
+
color: var(--text);
|
|
114
|
+
border-radius: 10px;
|
|
115
|
+
padding: 10px 12px;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.list button.active,
|
|
120
|
+
.list button:hover {
|
|
121
|
+
border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
|
|
122
|
+
background: #f0e9dc;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.list .id {
|
|
126
|
+
font-weight: 600;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.list .sub {
|
|
130
|
+
display: block;
|
|
131
|
+
margin-top: 4px;
|
|
132
|
+
color: var(--muted);
|
|
133
|
+
font-size: 0.78rem;
|
|
134
|
+
font-family: var(--mono);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.stage {
|
|
138
|
+
position: relative;
|
|
139
|
+
min-width: 0;
|
|
140
|
+
min-height: 0;
|
|
141
|
+
display: grid;
|
|
142
|
+
place-items: center;
|
|
143
|
+
background:
|
|
144
|
+
linear-gradient(180deg, #7ea0b5 0%, #b7c9d6 48%, #c5d2dc 72%, #8fa88a 100%);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#viewport-frame {
|
|
148
|
+
width: 100%;
|
|
149
|
+
height: 100%;
|
|
150
|
+
position: relative;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
#viewport-frame.letterbox {
|
|
154
|
+
box-shadow: 0 0 0 1px rgba(60, 70, 80, 0.18);
|
|
155
|
+
background: #0f1418;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
#viewport {
|
|
159
|
+
width: 100%;
|
|
160
|
+
height: 100%;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.gizmo-bar {
|
|
164
|
+
position: absolute;
|
|
165
|
+
top: 14px;
|
|
166
|
+
left: 14px;
|
|
167
|
+
z-index: 2;
|
|
168
|
+
display: flex;
|
|
169
|
+
flex-wrap: wrap;
|
|
170
|
+
align-items: center;
|
|
171
|
+
gap: 6px;
|
|
172
|
+
width: max-content;
|
|
173
|
+
max-width: calc(100% - 28px);
|
|
174
|
+
height: auto;
|
|
175
|
+
padding: 8px 10px;
|
|
176
|
+
border: 1px solid var(--line);
|
|
177
|
+
border-radius: 12px;
|
|
178
|
+
background: color-mix(in srgb, #fffdf8 86%, transparent);
|
|
179
|
+
backdrop-filter: blur(8px);
|
|
180
|
+
box-shadow: 0 8px 24px rgba(70, 55, 35, 0.06);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/* Must follow .gizmo-bar so top:auto beats top:14px (same specificity). */
|
|
184
|
+
.camera-bar {
|
|
185
|
+
top: auto;
|
|
186
|
+
bottom: 14px;
|
|
187
|
+
left: 50%;
|
|
188
|
+
right: auto;
|
|
189
|
+
transform: translateX(-50%);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.gizmo-bar[hidden] {
|
|
193
|
+
display: none;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.gizmo-label {
|
|
197
|
+
font-size: 0.75rem;
|
|
198
|
+
color: var(--muted);
|
|
199
|
+
margin-right: 2px;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.gizmo-btn {
|
|
203
|
+
padding: 6px 10px;
|
|
204
|
+
border-radius: 8px;
|
|
205
|
+
font-size: 0.8rem;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.gizmo-btn.active {
|
|
209
|
+
border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
|
|
210
|
+
background: #efe7d8;
|
|
211
|
+
color: var(--accent);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.gizmo-hint {
|
|
215
|
+
margin-left: 4px;
|
|
216
|
+
font-size: 0.72rem;
|
|
217
|
+
color: var(--muted);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.inspector[hidden] {
|
|
221
|
+
display: none;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.inspector header {
|
|
225
|
+
margin-bottom: 16px;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.inspector h2 {
|
|
229
|
+
margin: 0 0 6px;
|
|
230
|
+
font-size: 1.1rem;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.mono {
|
|
234
|
+
font-family: var(--mono);
|
|
235
|
+
font-size: 0.75rem;
|
|
236
|
+
color: var(--muted);
|
|
237
|
+
word-break: break-all;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
label {
|
|
241
|
+
display: grid;
|
|
242
|
+
gap: 6px;
|
|
243
|
+
margin-bottom: 12px;
|
|
244
|
+
font-size: 0.82rem;
|
|
245
|
+
color: var(--muted);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
input,
|
|
249
|
+
select,
|
|
250
|
+
textarea,
|
|
251
|
+
button {
|
|
252
|
+
font: inherit;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
input,
|
|
256
|
+
select,
|
|
257
|
+
textarea {
|
|
258
|
+
width: 100%;
|
|
259
|
+
border: 1px solid var(--line);
|
|
260
|
+
background: #fffdf8;
|
|
261
|
+
color: var(--text);
|
|
262
|
+
border-radius: 8px;
|
|
263
|
+
padding: 8px 10px;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
textarea {
|
|
267
|
+
resize: vertical;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
button {
|
|
271
|
+
border: 1px solid var(--line);
|
|
272
|
+
background: #efe8db;
|
|
273
|
+
color: var(--text);
|
|
274
|
+
border-radius: 10px;
|
|
275
|
+
padding: 10px 12px;
|
|
276
|
+
cursor: pointer;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
button.primary {
|
|
280
|
+
background: linear-gradient(180deg, #5b8fad, #3a6f8f);
|
|
281
|
+
border-color: #3a6f8f;
|
|
282
|
+
color: #fff;
|
|
283
|
+
font-weight: 600;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.actions {
|
|
287
|
+
display: grid;
|
|
288
|
+
gap: 8px;
|
|
289
|
+
margin: 16px 0 10px;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.meta {
|
|
293
|
+
margin-top: 8px;
|
|
294
|
+
padding: 10px;
|
|
295
|
+
border-radius: 8px;
|
|
296
|
+
background: #f0e9dc;
|
|
297
|
+
border: 1px dashed var(--line);
|
|
298
|
+
font-family: var(--mono);
|
|
299
|
+
font-size: 0.75rem;
|
|
300
|
+
color: var(--accent-2);
|
|
301
|
+
white-space: pre-wrap;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.hint {
|
|
305
|
+
color: var(--muted);
|
|
306
|
+
font-size: 0.78rem;
|
|
307
|
+
line-height: 1.45;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.hint code {
|
|
311
|
+
font-family: var(--mono);
|
|
312
|
+
color: var(--text);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
@media (max-width: 1100px) {
|
|
316
|
+
.shell {
|
|
317
|
+
grid-template-columns: 240px 1fr;
|
|
318
|
+
}
|
|
319
|
+
.inspector {
|
|
320
|
+
position: fixed;
|
|
321
|
+
right: 0;
|
|
322
|
+
top: 0;
|
|
323
|
+
bottom: 0;
|
|
324
|
+
width: min(320px, 90vw);
|
|
325
|
+
z-index: 5;
|
|
326
|
+
box-shadow: -12px 0 40px rgba(70, 55, 35, 0.12);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/** PBR/light/environment adaptation shared by Stage and game scenes. */
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
const srgb = (v) => new THREE.Color().setRGB(v[0], v[1], v[2], THREE.SRGBColorSpace);
|
|
4
|
+
function applyThreeAppearance(world, model, renderer, profile) {
|
|
5
|
+
if (profile.schema !== "evomeme.three_scene_profile.v1" || profile.three_revision !== THREE.REVISION || profile.renderer !== "webgl") throw new Error("Three.js 显示配置与运行时版本不一致");
|
|
6
|
+
const root = new THREE.Group();
|
|
7
|
+
root.name = "CanonicalAppearance";
|
|
8
|
+
const replaced = [], hidden = [];
|
|
9
|
+
const saved = { background: world.background, environment: world.environment, fog: world.fog, tone: renderer.toneMapping, exposure: renderer.toneMappingExposure, output: renderer.outputColorSpace, shadows: renderer.shadowMap.enabled, shadowType: renderer.shadowMap.type };
|
|
10
|
+
try {
|
|
11
|
+
model.traverse((o) => {
|
|
12
|
+
if (o.isLight) {
|
|
13
|
+
hidden.push([o, o.visible]);
|
|
14
|
+
o.visible = false;
|
|
15
|
+
}
|
|
16
|
+
if (!o.isMesh) return;
|
|
17
|
+
if (/(?:-colonly|-convcolonly)(?:[._]\d+)?$/i.test(o.name)) o.visible = false;
|
|
18
|
+
o.castShadow = o.visible;
|
|
19
|
+
o.receiveShadow = o.visible;
|
|
20
|
+
});
|
|
21
|
+
for (const item of profile.materials) {
|
|
22
|
+
let found = false;
|
|
23
|
+
model.traverse((o) => {
|
|
24
|
+
if (!o.isMesh) return;
|
|
25
|
+
const values = (Array.isArray(o.material) ? o.material : [o.material]).map((m) => {
|
|
26
|
+
if (m.name !== item.material_name) return m;
|
|
27
|
+
if (!m.isMeshStandardMaterial) throw new Error("材质覆盖要求 PBR:" + m.name);
|
|
28
|
+
found = true;
|
|
29
|
+
const copy = m.clone();
|
|
30
|
+
replaced.push(copy);
|
|
31
|
+
if (item.roughness !== void 0) copy.roughness = item.roughness;
|
|
32
|
+
if (item.metallic !== void 0) copy.metalness = item.metallic;
|
|
33
|
+
if (item.albedo_srgb) {
|
|
34
|
+
copy.color.copy(srgb(item.albedo_srgb));
|
|
35
|
+
copy.opacity = item.albedo_srgb[3];
|
|
36
|
+
}
|
|
37
|
+
if (item.emission_srgb) copy.emissive.copy(srgb(item.emission_srgb));
|
|
38
|
+
if (item.emission_energy !== void 0) copy.emissiveIntensity = item.emission_energy;
|
|
39
|
+
if (item.double_sided !== void 0) copy.side = item.double_sided ? THREE.DoubleSide : THREE.FrontSide;
|
|
40
|
+
return copy;
|
|
41
|
+
});
|
|
42
|
+
o.material = Array.isArray(o.material) ? values : values[0];
|
|
43
|
+
});
|
|
44
|
+
if (!found) throw new Error("Three.js 材质不存在:" + item.material_name);
|
|
45
|
+
}
|
|
46
|
+
const bounds = new THREE.Box3().setFromObject(model), size = Math.max(bounds.getSize(new THREE.Vector3()).length(), 1);
|
|
47
|
+
for (const item of profile.lights) {
|
|
48
|
+
const color = new THREE.Color().fromArray(item.color_linear);
|
|
49
|
+
const light = item.type === "directional" ? new THREE.DirectionalLight(color, item.energy) : item.type === "omni" ? new THREE.PointLight(color, item.energy, item.range) : new THREE.SpotLight(color, item.energy, item.range, THREE.MathUtils.degToRad(item.spot_angle_degrees), 0.25);
|
|
50
|
+
light.name = item.name;
|
|
51
|
+
light.position.fromArray(item.position);
|
|
52
|
+
if (light.target) {
|
|
53
|
+
const direction = new THREE.Vector3(0, 0, -1).applyQuaternion(new THREE.Quaternion().fromArray(item.quaternion_xyzw));
|
|
54
|
+
light.target.position.copy(light.position).add(direction);
|
|
55
|
+
root.add(light.target);
|
|
56
|
+
}
|
|
57
|
+
light.castShadow = item.shadow_enabled;
|
|
58
|
+
light.shadow.mapSize.set(1024, 1024);
|
|
59
|
+
if (light.isDirectionalLight) {
|
|
60
|
+
const direction = light.target.position.clone().sub(light.position).normalize(), center = bounds.getCenter(new THREE.Vector3());
|
|
61
|
+
light.position.copy(center).addScaledVector(direction, -size);
|
|
62
|
+
light.target.position.copy(center);
|
|
63
|
+
Object.assign(light.shadow.camera, { left: -size / 2, right: size / 2, top: size / 2, bottom: -size / 2, near: 0.01, far: size * 3 });
|
|
64
|
+
light.shadow.camera.updateProjectionMatrix();
|
|
65
|
+
}
|
|
66
|
+
root.add(light);
|
|
67
|
+
}
|
|
68
|
+
const env = profile.environment;
|
|
69
|
+
root.add(new THREE.AmbientLight(srgb(env.ambient_srgb), env.ambient_energy));
|
|
70
|
+
world.background = srgb(env.background_srgb);
|
|
71
|
+
world.environment = null;
|
|
72
|
+
world.fog = env.fog.enabled ? new THREE.FogExp2(srgb(env.fog.color_srgb), env.fog.density) : null;
|
|
73
|
+
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
74
|
+
renderer.toneMapping = { agx: THREE.AgXToneMapping, linear: THREE.LinearToneMapping, filmic: THREE.CineonToneMapping, aces: THREE.ACESFilmicToneMapping }[env.tonemapper];
|
|
75
|
+
renderer.toneMappingExposure = env.exposure;
|
|
76
|
+
renderer.shadowMap.enabled = true;
|
|
77
|
+
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
|
78
|
+
world.add(root);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
dispose();
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
function dispose() {
|
|
84
|
+
root.removeFromParent();
|
|
85
|
+
root.traverse((o) => o.shadow?.dispose());
|
|
86
|
+
replaced.forEach((m) => m.dispose());
|
|
87
|
+
hidden.forEach(([o, v]) => {
|
|
88
|
+
o.visible = v;
|
|
89
|
+
});
|
|
90
|
+
world.background = saved.background;
|
|
91
|
+
world.environment = saved.environment;
|
|
92
|
+
world.fog = saved.fog;
|
|
93
|
+
renderer.toneMapping = saved.tone;
|
|
94
|
+
renderer.toneMappingExposure = saved.exposure;
|
|
95
|
+
renderer.outputColorSpace = saved.output;
|
|
96
|
+
renderer.shadowMap.enabled = saved.shadows;
|
|
97
|
+
renderer.shadowMap.type = saved.shadowType;
|
|
98
|
+
}
|
|
99
|
+
return { root, update() {
|
|
100
|
+
}, dispose };
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
applyThreeAppearance
|
|
104
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2010-2024 three.js authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|