@2112-lab/central-plant 0.1.13 → 0.1.15
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/bundle/index.js +1619 -82
- package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +462 -0
- package/dist/cjs/src/index.js +4 -0
- package/dist/cjs/src/rendering/modelPreloader.js +241 -81
- package/dist/cjs/src/rendering/objProcessor.js +703 -0
- package/dist/cjs/src/testing/objProcessingDemo.js +254 -0
- package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +461 -2
- package/dist/esm/src/index.js +2 -0
- package/dist/esm/src/rendering/modelPreloader.js +241 -81
- package/dist/esm/src/rendering/objProcessor.js +678 -0
- package/dist/esm/src/testing/objProcessingDemo.js +249 -0
- package/package.json +1 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var modelPreloader = require('../rendering/modelPreloader.js');
|
|
7
|
+
var objProcessor = require('../rendering/objProcessor.js');
|
|
8
|
+
|
|
9
|
+
var ObjProcessingDemo = /*#__PURE__*/function () {
|
|
10
|
+
function ObjProcessingDemo() {
|
|
11
|
+
_rollupPluginBabelHelpers.classCallCheck(this, ObjProcessingDemo);
|
|
12
|
+
this.objProcessor = new objProcessor["default"]();
|
|
13
|
+
this.componentDictionary = null;
|
|
14
|
+
this.processedResults = new Map();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Load component dictionary
|
|
19
|
+
* @returns {Promise<Object>} Component dictionary
|
|
20
|
+
*/
|
|
21
|
+
return _rollupPluginBabelHelpers.createClass(ObjProcessingDemo, [{
|
|
22
|
+
key: "loadComponentDictionary",
|
|
23
|
+
value: (function () {
|
|
24
|
+
var _loadComponentDictionary = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee() {
|
|
25
|
+
var response, _t;
|
|
26
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
|
|
27
|
+
while (1) switch (_context.n) {
|
|
28
|
+
case 0:
|
|
29
|
+
_context.p = 0;
|
|
30
|
+
_context.n = 1;
|
|
31
|
+
return fetch('/library/component-dictionary.json');
|
|
32
|
+
case 1:
|
|
33
|
+
response = _context.v;
|
|
34
|
+
_context.n = 2;
|
|
35
|
+
return response.json();
|
|
36
|
+
case 2:
|
|
37
|
+
this.componentDictionary = _context.v;
|
|
38
|
+
return _context.a(2, this.componentDictionary);
|
|
39
|
+
case 3:
|
|
40
|
+
_context.p = 3;
|
|
41
|
+
_t = _context.v;
|
|
42
|
+
throw _t;
|
|
43
|
+
case 4:
|
|
44
|
+
return _context.a(2);
|
|
45
|
+
}
|
|
46
|
+
}, _callee, this, [[0, 3]]);
|
|
47
|
+
}));
|
|
48
|
+
function loadComponentDictionary() {
|
|
49
|
+
return _loadComponentDictionary.apply(this, arguments);
|
|
50
|
+
}
|
|
51
|
+
return loadComponentDictionary;
|
|
52
|
+
}()
|
|
53
|
+
/**
|
|
54
|
+
* Get all OBJ models from component dictionary
|
|
55
|
+
* @returns {Array} Array of OBJ model configurations
|
|
56
|
+
*/
|
|
57
|
+
)
|
|
58
|
+
}, {
|
|
59
|
+
key: "getObjModels",
|
|
60
|
+
value: function getObjModels() {
|
|
61
|
+
var _this = this;
|
|
62
|
+
if (!this.componentDictionary) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
var objModels = [];
|
|
66
|
+
Object.keys(this.componentDictionary).forEach(function (componentId) {
|
|
67
|
+
var component = _this.componentDictionary[componentId];
|
|
68
|
+
if (component.modelType === 'obj') {
|
|
69
|
+
objModels.push({
|
|
70
|
+
componentId: componentId,
|
|
71
|
+
modelKey: component.modelKey,
|
|
72
|
+
name: component.name,
|
|
73
|
+
boundingBox: component.boundingBox
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return objModels;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Process all OBJ models and store in IndexedDB
|
|
82
|
+
* @returns {Promise<Array>} Array of processing results
|
|
83
|
+
*/
|
|
84
|
+
}, {
|
|
85
|
+
key: "processAllObjModels",
|
|
86
|
+
value: (function () {
|
|
87
|
+
var _processAllObjModels = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee2() {
|
|
88
|
+
var objModels, processingResults, _iterator, _step, objModel, cachedModelData, result, serializedData, _t3;
|
|
89
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context2) {
|
|
90
|
+
while (1) switch (_context2.n) {
|
|
91
|
+
case 0:
|
|
92
|
+
if (this.componentDictionary) {
|
|
93
|
+
_context2.n = 1;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
_context2.n = 1;
|
|
97
|
+
return this.loadComponentDictionary();
|
|
98
|
+
case 1:
|
|
99
|
+
// Get all OBJ models
|
|
100
|
+
objModels = this.getObjModels();
|
|
101
|
+
if (!(objModels.length === 0)) {
|
|
102
|
+
_context2.n = 2;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
return _context2.a(2, []);
|
|
106
|
+
case 2:
|
|
107
|
+
_context2.n = 3;
|
|
108
|
+
return modelPreloader["default"].preloadAllModels(this.componentDictionary);
|
|
109
|
+
case 3:
|
|
110
|
+
if (!this.objProcessor.idbSupported) {
|
|
111
|
+
_context2.n = 4;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
_context2.n = 4;
|
|
115
|
+
return this.objProcessor.initializeIDB();
|
|
116
|
+
case 4:
|
|
117
|
+
processingResults = []; // Process each OBJ model
|
|
118
|
+
_iterator = _rollupPluginBabelHelpers.createForOfIteratorHelper(objModels);
|
|
119
|
+
_context2.p = 5;
|
|
120
|
+
_iterator.s();
|
|
121
|
+
case 6:
|
|
122
|
+
if ((_step = _iterator.n()).done) {
|
|
123
|
+
_context2.n = 12;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
objModel = _step.value;
|
|
127
|
+
_context2.p = 7;
|
|
128
|
+
// Get the cached model from preloader
|
|
129
|
+
cachedModelData = modelPreloader["default"].modelCache.get(objModel.modelKey);
|
|
130
|
+
if (!(!cachedModelData || !cachedModelData.isObjModel)) {
|
|
131
|
+
_context2.n = 8;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
return _context2.a(3, 11);
|
|
135
|
+
case 8:
|
|
136
|
+
// Extract processing results
|
|
137
|
+
result = {
|
|
138
|
+
componentId: objModel.componentId,
|
|
139
|
+
modelKey: objModel.modelKey,
|
|
140
|
+
name: objModel.name,
|
|
141
|
+
boundingBox: objModel.boundingBox,
|
|
142
|
+
stats: cachedModelData.geometryStats,
|
|
143
|
+
originalObject: cachedModelData.originalObject,
|
|
144
|
+
processedGeometry: cachedModelData.processedGeometry,
|
|
145
|
+
materials: cachedModelData.materials
|
|
146
|
+
};
|
|
147
|
+
processingResults.push(result);
|
|
148
|
+
this.processedResults.set(objModel.modelKey, result);
|
|
149
|
+
|
|
150
|
+
// Store in IndexedDB if supported
|
|
151
|
+
if (!(this.objProcessor.idbSupported && result.processedGeometry)) {
|
|
152
|
+
_context2.n = 9;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
serializedData = this.objProcessor.serializeGeometry(result.processedGeometry);
|
|
156
|
+
_context2.n = 9;
|
|
157
|
+
return this.objProcessor.storeGeometryInIDB(objModel.modelKey, serializedData);
|
|
158
|
+
case 9:
|
|
159
|
+
_context2.n = 11;
|
|
160
|
+
break;
|
|
161
|
+
case 10:
|
|
162
|
+
_context2.p = 10;
|
|
163
|
+
_context2.v;
|
|
164
|
+
return _context2.a(3, 11);
|
|
165
|
+
case 11:
|
|
166
|
+
_context2.n = 6;
|
|
167
|
+
break;
|
|
168
|
+
case 12:
|
|
169
|
+
_context2.n = 14;
|
|
170
|
+
break;
|
|
171
|
+
case 13:
|
|
172
|
+
_context2.p = 13;
|
|
173
|
+
_t3 = _context2.v;
|
|
174
|
+
_iterator.e(_t3);
|
|
175
|
+
case 14:
|
|
176
|
+
_context2.p = 14;
|
|
177
|
+
_iterator.f();
|
|
178
|
+
return _context2.f(14);
|
|
179
|
+
case 15:
|
|
180
|
+
return _context2.a(2, processingResults);
|
|
181
|
+
}
|
|
182
|
+
}, _callee2, this, [[7, 10], [5, 13, 14, 15]]);
|
|
183
|
+
}));
|
|
184
|
+
function processAllObjModels() {
|
|
185
|
+
return _processAllObjModels.apply(this, arguments);
|
|
186
|
+
}
|
|
187
|
+
return processAllObjModels;
|
|
188
|
+
}()
|
|
189
|
+
/**
|
|
190
|
+
* Run the simplified demo - process and store in IndexedDB
|
|
191
|
+
* @returns {Promise<Object>} Demo results
|
|
192
|
+
*/
|
|
193
|
+
)
|
|
194
|
+
}, {
|
|
195
|
+
key: "run",
|
|
196
|
+
value: (function () {
|
|
197
|
+
var _run = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee3() {
|
|
198
|
+
var processingResults, _t4;
|
|
199
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context3) {
|
|
200
|
+
while (1) switch (_context3.n) {
|
|
201
|
+
case 0:
|
|
202
|
+
_context3.p = 0;
|
|
203
|
+
_context3.n = 1;
|
|
204
|
+
return this.processAllObjModels();
|
|
205
|
+
case 1:
|
|
206
|
+
processingResults = _context3.v;
|
|
207
|
+
return _context3.a(2, {
|
|
208
|
+
processingResults: processingResults,
|
|
209
|
+
totalModelsProcessed: processingResults.length,
|
|
210
|
+
success: true
|
|
211
|
+
});
|
|
212
|
+
case 2:
|
|
213
|
+
_context3.p = 2;
|
|
214
|
+
_t4 = _context3.v;
|
|
215
|
+
return _context3.a(2, {
|
|
216
|
+
processingResults: [],
|
|
217
|
+
totalModelsProcessed: 0,
|
|
218
|
+
success: false,
|
|
219
|
+
error: _t4.message
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}, _callee3, this, [[0, 2]]);
|
|
223
|
+
}));
|
|
224
|
+
function run() {
|
|
225
|
+
return _run.apply(this, arguments);
|
|
226
|
+
}
|
|
227
|
+
return run;
|
|
228
|
+
}()
|
|
229
|
+
/**
|
|
230
|
+
* Get processing results for external use
|
|
231
|
+
* @returns {Map} Map of processing results
|
|
232
|
+
*/
|
|
233
|
+
)
|
|
234
|
+
}, {
|
|
235
|
+
key: "getResults",
|
|
236
|
+
value: function getResults() {
|
|
237
|
+
return this.processedResults;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get geometry by model key
|
|
242
|
+
* @param {string} modelKey - The model key
|
|
243
|
+
* @returns {Object|null} Processing result or null
|
|
244
|
+
*/
|
|
245
|
+
}, {
|
|
246
|
+
key: "getGeometry",
|
|
247
|
+
value: function getGeometry(modelKey) {
|
|
248
|
+
return this.processedResults.get(modelKey) || null;
|
|
249
|
+
}
|
|
250
|
+
}]);
|
|
251
|
+
}(); // Export for use
|
|
252
|
+
|
|
253
|
+
exports.ObjProcessingDemo = ObjProcessingDemo;
|
|
254
|
+
exports["default"] = ObjProcessingDemo;
|