|
1 | | -//@ts-nocheck |
2 | 1 | import { BasePlaygroundScene } from '../baseScene' |
3 | 2 | import { EntityDebugFlags, EntityMesh, rendererSpecialHandled } from '../../viewer/three/entity/EntityMesh' |
| 3 | +import { displayEntitiesDebugList } from '../allEntitiesDebug' |
4 | 4 |
|
5 | 5 | export default class AllEntities extends BasePlaygroundScene { |
6 | 6 | continuousRender = false |
7 | 7 | enableCameraControls = false |
8 | 8 |
|
9 | 9 | async initData () { |
10 | 10 | await super.initData() |
11 | | - |
12 | | - // Create results container |
13 | | - const container = document.createElement('div') |
14 | | - container.style.cssText = ` |
15 | | - position: fixed; |
16 | | - top: 50%; |
17 | | - left: 50%; |
18 | | - transform: translate(-50%, -50%); |
19 | | - max-height: 90vh; |
20 | | - overflow-y: auto; |
21 | | - background: rgba(0,0,0,0.8); |
22 | | - color: white; |
23 | | - padding: 20px; |
24 | | - border-radius: 8px; |
25 | | - font-family: monospace; |
26 | | - min-width: 400px; |
27 | | - ` |
28 | | - document.body.appendChild(container) |
29 | | - |
30 | | - // Add title |
31 | | - const title = document.createElement('h2') |
32 | | - title.textContent = 'Minecraft Entity Support' |
33 | | - title.style.cssText = 'margin-top: 0; text-align: center;' |
34 | | - container.appendChild(title) |
35 | | - |
36 | | - // Test entities |
37 | | - const results: Array<{ |
38 | | - entity: string; |
39 | | - supported: boolean; |
40 | | - type?: 'obj' | 'bedrock'; |
41 | | - mappedFrom?: string; |
42 | | - textureMap?: boolean; |
43 | | - errors?: string[]; |
44 | | - }> = [] |
45 | | - const { mcData } = window |
46 | | - const entityNames = Object.keys(mcData.entitiesArray.reduce((acc, entity) => { |
47 | | - acc[entity.name] = true |
48 | | - return acc |
49 | | - }, {})) |
50 | | - |
51 | | - // Add loading indicator |
52 | | - const loading = document.createElement('div') |
53 | | - loading.textContent = 'Testing entities...' |
54 | | - loading.style.textAlign = 'center' |
55 | | - container.appendChild(loading) |
56 | | - |
57 | | - for (const entity of entityNames) { |
58 | | - const debugFlags: EntityDebugFlags = {} |
59 | | - |
60 | | - try { |
61 | | - // eslint-disable-next-line no-new |
62 | | - new EntityMesh(this.version, entity, viewer.world, {}, debugFlags) |
63 | | - |
64 | | - results.push({ |
65 | | - entity, |
66 | | - supported: !!debugFlags.type || rendererSpecialHandled.includes(entity), |
67 | | - type: debugFlags.type, |
68 | | - mappedFrom: debugFlags.tempMap, |
69 | | - textureMap: debugFlags.textureMap, |
70 | | - errors: debugFlags.errors |
71 | | - }) |
72 | | - } catch (e) { |
73 | | - console.error(e) |
74 | | - results.push({ |
75 | | - entity, |
76 | | - supported: false, |
77 | | - mappedFrom: debugFlags.tempMap |
78 | | - }) |
79 | | - } |
80 | | - } |
81 | | - |
82 | | - // Remove loading indicator |
83 | | - loading.remove() |
84 | | - |
85 | | - const createSection = (title: string, items: any[], filter: (item: any) => boolean) => { |
86 | | - const section = document.createElement('div') |
87 | | - section.style.marginBottom = '20px' |
88 | | - |
89 | | - const sectionTitle = document.createElement('h3') |
90 | | - sectionTitle.textContent = title |
91 | | - sectionTitle.style.textAlign = 'center' |
92 | | - section.appendChild(sectionTitle) |
93 | | - |
94 | | - const list = document.createElement('ul') |
95 | | - list.style.cssText = 'padding-left: 20px; list-style-type: none; margin: 0;' |
96 | | - |
97 | | - const filteredItems = items.filter(filter) |
98 | | - for (const item of filteredItems) { |
99 | | - const listItem = document.createElement('li') |
100 | | - listItem.style.cssText = 'line-height: 1.4; margin: 8px 0;' |
101 | | - |
102 | | - const entityName = document.createElement('strong') |
103 | | - entityName.style.cssText = 'user-select: text;-webkit-user-select: text;' |
104 | | - entityName.textContent = item.entity |
105 | | - listItem.appendChild(entityName) |
106 | | - |
107 | | - let text = '' |
108 | | - if (item.mappedFrom) { |
109 | | - text += ` -> ${item.mappedFrom}` |
110 | | - } |
111 | | - if (item.type) { |
112 | | - text += ` - ${item.type}` |
113 | | - } |
114 | | - if (item.textureMap) { |
115 | | - text += ' ⚠️' |
116 | | - } |
117 | | - if (item.errors) { |
118 | | - text += ' ❌' |
119 | | - } |
120 | | - |
121 | | - listItem.appendChild(document.createTextNode(text)) |
122 | | - list.appendChild(listItem) |
123 | | - } |
124 | | - |
125 | | - section.appendChild(list) |
126 | | - return { section, count: filteredItems.length } |
127 | | - } |
128 | | - |
129 | | - // Sort results - bedrock first |
130 | | - results.sort((a, b) => { |
131 | | - if (a.type === 'bedrock' && b.type !== 'bedrock') return -1 |
132 | | - if (a.type !== 'bedrock' && b.type === 'bedrock') return 1 |
133 | | - return a.entity.localeCompare(b.entity) |
134 | | - }) |
135 | | - |
136 | | - // Add sections |
137 | | - const sections = [ |
138 | | - { |
139 | | - title: '❌ Unsupported Entities', |
140 | | - filter: (r: any) => !r.supported && !r.mappedFrom |
141 | | - }, |
142 | | - { |
143 | | - title: '⚠️ Partially Supported Entities', |
144 | | - filter: (r: any) => r.mappedFrom |
145 | | - }, |
146 | | - { |
147 | | - title: '✅ Supported Entities', |
148 | | - filter: (r: any) => r.supported && !r.mappedFrom |
149 | | - } |
150 | | - ] |
151 | | - |
152 | | - for (const { title, filter } of sections) { |
153 | | - const { section, count } = createSection(title, results, filter) |
154 | | - if (count > 0) { |
155 | | - container.appendChild(section) |
156 | | - } |
157 | | - } |
158 | | - |
159 | | - // log object with errors per entity |
160 | | - const errors = results.filter(r => r.errors).map(r => ({ |
161 | | - entity: r.entity, |
162 | | - errors: r.errors |
163 | | - })) |
164 | | - console.log(errors) |
| 11 | + displayEntitiesDebugList(this.version) |
165 | 12 | } |
166 | 13 | } |
0 commit comments