@voltstack/headless-rasterizer 1.0.0 → 1.0.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/LICENSE +21 -0
- package/binding.gyp +2 -2
- package/package.json +1 -1
- package/src/rasterizer/rasterizer.h +4 -22
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 VoltLabs Research
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
package/binding.gyp
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"include_dirs": [],
|
|
7
7
|
"cflags!": ["-fno-exceptions"],
|
|
8
8
|
"cflags_cc!": ["-fno-exceptions"],
|
|
9
|
-
"cflags": ["-O3", "-
|
|
10
|
-
"cflags_cc": ["-O3", "-
|
|
9
|
+
"cflags": ["-O3", "-ffast-math", "-pthread"],
|
|
10
|
+
"cflags_cc": ["-O3", "-ffast-math", "-std=c++17", "-pthread"],
|
|
11
11
|
"ldflags": ["-pthread"],
|
|
12
12
|
"defines": ["NAPI_CPP_EXCEPTIONS"]
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -213,7 +213,6 @@ private:
|
|
|
213
213
|
struct GLBView{
|
|
214
214
|
const float* pos = nullptr;
|
|
215
215
|
const float* col = nullptr;
|
|
216
|
-
const float* normals = nullptr;
|
|
217
216
|
const uint16_t* idx16 = nullptr;
|
|
218
217
|
const uint32_t* idx32 = nullptr;
|
|
219
218
|
size_t vertexCount = 0;
|
|
@@ -229,14 +228,6 @@ private:
|
|
|
229
228
|
return std::atoi(json.c_str() + p + k.size());
|
|
230
229
|
}
|
|
231
230
|
|
|
232
|
-
// Find integer value for a key starting from a given position
|
|
233
|
-
static int findIntFrom(const std::string& json, const char* key, size_t startPos){
|
|
234
|
-
std::string k = std::string("\"") + key + "\":";
|
|
235
|
-
size_t p = json.find(k, startPos);
|
|
236
|
-
if(p == std::string::npos) return -1;
|
|
237
|
-
return std::atoi(json.c_str() + p + k.size());
|
|
238
|
-
}
|
|
239
|
-
|
|
240
231
|
// Parse bufferView info: byteOffset and byteLength
|
|
241
232
|
struct BufferViewInfo {
|
|
242
233
|
size_t byteOffset = 0;
|
|
@@ -270,9 +261,9 @@ private:
|
|
|
270
261
|
if (currentIndex == index) {
|
|
271
262
|
// Found our bufferView, parse it
|
|
272
263
|
std::string bvJson = json.substr(objStart, pos - objStart + 1);
|
|
273
|
-
info.byteOffset =
|
|
264
|
+
info.byteOffset = findInt(bvJson, "byteOffset");
|
|
274
265
|
if (info.byteOffset == (size_t)-1) info.byteOffset = 0;
|
|
275
|
-
info.byteLength =
|
|
266
|
+
info.byteLength = findInt(bvJson, "byteLength");
|
|
276
267
|
if (info.byteLength == (size_t)-1) info.byteLength = 0;
|
|
277
268
|
return info;
|
|
278
269
|
}
|
|
@@ -348,9 +339,8 @@ private:
|
|
|
348
339
|
// Layout for mesh with colors: BV0=positions, BV1=normals, BV2=colors, BV3=indices
|
|
349
340
|
// Layout for mesh without colors: BV0=positions, BV1=normals, BV2=indices
|
|
350
341
|
BufferViewInfo bvPos = parseBufferView(json, 0);
|
|
351
|
-
BufferViewInfo bvNorm = parseBufferView(json, 1);
|
|
352
342
|
BufferViewInfo bvCol, bvIdx;
|
|
353
|
-
|
|
343
|
+
|
|
354
344
|
if(hasColors){
|
|
355
345
|
bvCol = parseBufferView(json, 2);
|
|
356
346
|
bvIdx = parseBufferView(json, 3);
|
|
@@ -365,7 +355,6 @@ private:
|
|
|
365
355
|
|
|
366
356
|
// Validate offsets are within binary buffer bounds
|
|
367
357
|
if(bvPos.byteOffset + bvPos.byteLength > binLen ||
|
|
368
|
-
bvNorm.byteOffset + bvNorm.byteLength > binLen ||
|
|
369
358
|
bvIdx.byteOffset + bvIdx.byteLength > binLen){
|
|
370
359
|
return false;
|
|
371
360
|
}
|
|
@@ -390,8 +379,7 @@ private:
|
|
|
390
379
|
|
|
391
380
|
// Set pointers using bufferView offsets
|
|
392
381
|
out.pos = (const float*)(bin + bvPos.byteOffset);
|
|
393
|
-
|
|
394
|
-
|
|
382
|
+
|
|
395
383
|
if(hasColors && bvCol.byteLength > 0){
|
|
396
384
|
out.col = (const float*)(bin + bvCol.byteOffset);
|
|
397
385
|
}
|
|
@@ -427,12 +415,6 @@ private:
|
|
|
427
415
|
struct Mat4{
|
|
428
416
|
float m[16];
|
|
429
417
|
|
|
430
|
-
static Mat4 identity(){
|
|
431
|
-
Mat4 r{};
|
|
432
|
-
r.m[0] = r.m[5] = r.m[10] = r.m[15] = 1.f;
|
|
433
|
-
return r;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
418
|
static Mat4 lookAt(
|
|
437
419
|
float eyeX,
|
|
438
420
|
float eyeY,
|