rm-webgpu-compute-tasks 0.0.7 → 0.0.8
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/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +14 -7
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -457,7 +457,12 @@ async function initWebgpu(opt = {}) {
|
|
|
457
457
|
if (!navigator.gpu) throw new Error("该环境不支持webgpu");
|
|
458
458
|
if (!adapter) adapter = await navigator.gpu.requestAdapter(opt);
|
|
459
459
|
if (!adapter) throw new Error("获取适配器失败");
|
|
460
|
-
device = await adapter.requestDevice(
|
|
460
|
+
device = await adapter.requestDevice({
|
|
461
|
+
requiredLimits: {
|
|
462
|
+
maxBufferSize: adapter.limits.maxBufferSize
|
|
463
|
+
},
|
|
464
|
+
...opt
|
|
465
|
+
});
|
|
461
466
|
if (!adapter) throw new Error("获取设备失败");
|
|
462
467
|
GpuComputed.set(adapter, device);
|
|
463
468
|
return { device, adapter };
|
|
@@ -1333,7 +1338,7 @@ class ShaderMaterial {
|
|
|
1333
1338
|
set value(v) {
|
|
1334
1339
|
if (getUniformType(v, uniforms[key]?.atomic) !== type) return;
|
|
1335
1340
|
v = set(v, value_);
|
|
1336
|
-
if ("copy" in value_ && typeof value_.copy === "function") value_.copy(v);
|
|
1341
|
+
if (typeof value_ === "object" && "copy" in value_ && typeof value_.copy === "function") value_.copy(v);
|
|
1337
1342
|
else value_ = v;
|
|
1338
1343
|
}
|
|
1339
1344
|
};
|
|
@@ -2570,7 +2575,7 @@ class PointCloudsIndexMaterial extends ShaderMaterial {
|
|
|
2570
2575
|
cameraMat: { value: new Matrix3() },
|
|
2571
2576
|
T_cw: { value: new Matrix4() },
|
|
2572
2577
|
imageSize: { value: new Vector2(width, height) },
|
|
2573
|
-
groundZ: { value: -
|
|
2578
|
+
groundZ: { value: -1 },
|
|
2574
2579
|
depth: { value: depthU32, write: true, atomic: true }
|
|
2575
2580
|
},
|
|
2576
2581
|
topology: "point-list"
|
|
@@ -3165,7 +3170,7 @@ function getInfo(itemsFile, cindex) {
|
|
|
3165
3170
|
(index) => itemPosition.push(
|
|
3166
3171
|
path[index].x,
|
|
3167
3172
|
path[index].y,
|
|
3168
|
-
cindex * 200 + i
|
|
3173
|
+
cindex * 200 + i + 1
|
|
3169
3174
|
)
|
|
3170
3175
|
)
|
|
3171
3176
|
);
|
|
@@ -3185,7 +3190,8 @@ async function sopc_(opt) {
|
|
|
3185
3190
|
erodeMaskSize = 3,
|
|
3186
3191
|
kernelSize = 15,
|
|
3187
3192
|
gridSize = 0.05,
|
|
3188
|
-
gridAmount = 2
|
|
3193
|
+
gridAmount = 2,
|
|
3194
|
+
groundZ = 0
|
|
3189
3195
|
} = opt;
|
|
3190
3196
|
console.log("开始计算");
|
|
3191
3197
|
let t = performance.now();
|
|
@@ -3203,6 +3209,7 @@ async function sopc_(opt) {
|
|
|
3203
3209
|
polyAreaIndexMaterial
|
|
3204
3210
|
);
|
|
3205
3211
|
camera.position.set(1, 1, 1);
|
|
3212
|
+
pcIndexMaterial.groundZ = groundZ;
|
|
3206
3213
|
console.log("文件加载耗时:", performance.now() - t);
|
|
3207
3214
|
t = performance.now();
|
|
3208
3215
|
for (let i = 0; i < itemsFiles.length; i++) {
|
|
@@ -3241,7 +3248,7 @@ async function sopc_(opt) {
|
|
|
3241
3248
|
arrayMap = new ArrayMap();
|
|
3242
3249
|
map.set(fileIndex, arrayMap);
|
|
3243
3250
|
}
|
|
3244
|
-
arrayMap.append(itemIndex, i);
|
|
3251
|
+
arrayMap.append(itemIndex - 1, i);
|
|
3245
3252
|
}
|
|
3246
3253
|
const transcendingCreation = ["window", "calcony railing", "glass balcony railing", "metal balcony railing", "temporary construction guardrail"];
|
|
3247
3254
|
const results = new Array(itemsFiles.length);
|
|
@@ -3273,11 +3280,11 @@ async function sopc_(opt) {
|
|
|
3273
3280
|
const type = itemsFile.sam3Objects[itemIndex].category;
|
|
3274
3281
|
const isTranscendingCreation = transcendingCreation.includes(type);
|
|
3275
3282
|
pointarr = sort(pointarr, isTranscendingCreation, itemsFile.position)[0];
|
|
3276
|
-
if (pointarr.length <= 6 * 3) return;
|
|
3277
3283
|
if (!results[fileIndex]) results[fileIndex] = new Array(itemsFiles[fileIndex].sam3Objects.length).fill([]);
|
|
3278
3284
|
results[fileIndex][itemIndex] = pointarr;
|
|
3279
3285
|
});
|
|
3280
3286
|
});
|
|
3287
|
+
console.log(results, itemsFiles[0]);
|
|
3281
3288
|
renderer.renderTarget = null;
|
|
3282
3289
|
renderer.depthTarget = null;
|
|
3283
3290
|
console.log("整理结果消耗时间:", performance.now() - t, "点云数量", pointsArray.length / 3, "文件数量", itemsFiles.length);
|