@playdrop/playdrop-cli 0.7.15 → 0.7.16
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/config/client-meta.json +1 -1
- package/node_modules/@playdrop/ai-client/dist/index.js +461 -444
- package/node_modules/@playdrop/ai-client/package.json +1 -1
- package/node_modules/@playdrop/api-client/dist/client.js +903 -882
- package/node_modules/@playdrop/api-client/dist/core/errors.js +69 -45
- package/node_modules/@playdrop/api-client/dist/core/request.js +188 -159
- package/node_modules/@playdrop/api-client/dist/domains/admin.js +516 -491
- package/node_modules/@playdrop/api-client/dist/domains/ai.js +40 -14
- package/node_modules/@playdrop/api-client/dist/domains/apps.js +480 -462
- package/node_modules/@playdrop/api-client/dist/domains/asset-packs.js +439 -419
- package/node_modules/@playdrop/api-client/dist/domains/assets.js +696 -676
- package/node_modules/@playdrop/api-client/dist/domains/auth.js +346 -320
- package/node_modules/@playdrop/api-client/dist/domains/comments.js +124 -98
- package/node_modules/@playdrop/api-client/dist/domains/free-credits.js +91 -65
- package/node_modules/@playdrop/api-client/dist/domains/me.js +71 -45
- package/node_modules/@playdrop/api-client/dist/domains/payments.js +407 -386
- package/node_modules/@playdrop/api-client/dist/domains/player-meta.js +144 -118
- package/node_modules/@playdrop/api-client/dist/domains/search.js +117 -104
- package/node_modules/@playdrop/api-client/dist/domains/tags.js +188 -162
- package/node_modules/@playdrop/api-client/dist/index.js +993 -552
- package/node_modules/@playdrop/api-client/package.json +1 -1
- package/node_modules/@playdrop/boxel-three/dist/src/animations.js +84 -62
- package/node_modules/@playdrop/boxel-three/dist/src/builders.js +341 -308
- package/node_modules/@playdrop/boxel-three/dist/src/context.js +55 -29
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.js +856 -858
- package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.js +267 -261
- package/node_modules/@playdrop/boxel-three/dist/src/index.js +64 -15
- package/node_modules/@playdrop/boxel-three/dist/src/instantiate.js +89 -63
- package/node_modules/@playdrop/boxel-three/dist/src/nodes.js +81 -56
- package/node_modules/@playdrop/boxel-three/dist/src/overlays.js +112 -86
- package/node_modules/@playdrop/boxel-three/dist/src/primitives.js +45 -17
- package/node_modules/@playdrop/boxel-three/dist/src/scene.js +160 -136
- package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.js +582 -584
- package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.js +123 -97
- package/node_modules/@playdrop/boxel-three/dist/src/textures.js +207 -182
- package/node_modules/@playdrop/boxel-three/dist/src/types.js +15 -1
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.js +451 -425
- package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.js +109 -84
- package/node_modules/@playdrop/boxel-three/dist/test/export-image.playwright.test.js +127 -106
- package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.js +73 -51
- package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.js +97 -79
- package/node_modules/@playdrop/boxel-three/dist/test/index.test.js +29 -7
- package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.js +80 -60
- package/node_modules/@playdrop/boxel-three/dist/test/overlays.test.js +41 -19
- package/node_modules/@playdrop/boxel-three/dist/test/scene-filter.test.js +72 -50
- package/node_modules/@playdrop/boxel-three/dist/test/scene-smoke.test.js +84 -62
- package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.js +69 -47
- package/node_modules/@playdrop/boxel-three/dist/test/textured-overlay.test.js +129 -109
- package/node_modules/@playdrop/boxel-three/dist/test/voxels.test.js +40 -18
- package/node_modules/@playdrop/boxel-three/package.json +1 -1
- package/node_modules/@playdrop/config/client-meta.json +1 -1
- package/node_modules/@playdrop/types/dist/api.js +289 -203
- package/node_modules/@playdrop/types/dist/app-capability-filters.js +112 -62
- package/node_modules/@playdrop/types/dist/app.js +91 -45
- package/node_modules/@playdrop/types/dist/asset-pack.js +37 -5
- package/node_modules/@playdrop/types/dist/asset-spec.js +170 -90
- package/node_modules/@playdrop/types/dist/asset.js +186 -108
- package/node_modules/@playdrop/types/dist/content-license.js +49 -15
- package/node_modules/@playdrop/types/dist/creator-public-image.js +60 -32
- package/node_modules/@playdrop/types/dist/ecs.js +102 -82
- package/node_modules/@playdrop/types/dist/engine-builtins.js +603 -573
- package/node_modules/@playdrop/types/dist/entity.js +63 -53
- package/node_modules/@playdrop/types/dist/graph.js +116 -80
- package/node_modules/@playdrop/types/dist/index.js +47 -20
- package/node_modules/@playdrop/types/dist/owned-assets.js +55 -33
- package/node_modules/@playdrop/types/dist/player-meta.js +151 -100
- package/node_modules/@playdrop/types/dist/realtime.js +27 -7
- package/node_modules/@playdrop/types/dist/version.js +182 -124
- package/node_modules/@playdrop/types/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,88 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const height = quad.size[1];
|
|
36
|
-
const base = [quad.origin[0], quad.origin[1], quad.origin[2]];
|
|
37
|
-
base[axis] = quad.plane;
|
|
38
|
-
const corners = quad.normal === 1
|
|
39
|
-
? [
|
|
40
|
-
[0, 0],
|
|
41
|
-
[width, 0],
|
|
42
|
-
[width, height],
|
|
43
|
-
[0, height],
|
|
44
|
-
]
|
|
45
|
-
: [
|
|
46
|
-
[0, 0],
|
|
47
|
-
[0, height],
|
|
48
|
-
[width, height],
|
|
49
|
-
[width, 0],
|
|
50
|
-
];
|
|
51
|
-
const normalVector = [0, 0, 0];
|
|
52
|
-
normalVector[axis] = quad.normal;
|
|
53
|
-
corners.forEach(([uOffset, vOffset]) => {
|
|
54
|
-
const vertex = [base[0], base[1], base[2]];
|
|
55
|
-
vertex[uAxis] = base[uAxis] + uOffset;
|
|
56
|
-
vertex[vAxis] = base[vAxis] + vOffset;
|
|
57
|
-
positions.push(vertex[0] * cellSizes[0] - halfSize[0], vertex[1] * cellSizes[1] - halfSize[1], vertex[2] * cellSizes[2] - halfSize[2]);
|
|
58
|
-
normals.push(normalVector[0], normalVector[1], normalVector[2]);
|
|
59
|
-
const u = width > 0 ? uOffset / width : 0;
|
|
60
|
-
const v = height > 0 ? vOffset / height : 0;
|
|
61
|
-
uvs.push(u, v);
|
|
62
|
-
});
|
|
63
|
-
const startIndex = indices.length;
|
|
64
|
-
indices.push(baseIndex, baseIndex + 1, baseIndex + 2, baseIndex, baseIndex + 2, baseIndex + 3);
|
|
65
|
-
const lastGroup = groups[groups.length - 1];
|
|
66
|
-
if (lastGroup && lastGroup.material === quad.material && lastGroup.start + lastGroup.count === startIndex) {
|
|
67
|
-
lastGroup.count += 6;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
groups.push({ material: quad.material, start: startIndex, count: 6 });
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
quads.forEach(pushQuad);
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var mesher_exports = {};
|
|
19
|
+
__export(mesher_exports, {
|
|
20
|
+
buildVoxelMesh: () => buildVoxelMesh,
|
|
21
|
+
hasVoxelData: () => hasVoxelData
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(mesher_exports);
|
|
24
|
+
var import_boxel_core = require("@playdrop/boxel-core");
|
|
25
|
+
function buildVoxelMesh(options) {
|
|
26
|
+
const { voxels, dimensions, size } = options;
|
|
27
|
+
const quads = (0, import_boxel_core.generateGreedyQuads)(voxels, dimensions);
|
|
28
|
+
const halfSize = [size[0] / 2, size[1] / 2, size[2] / 2];
|
|
29
|
+
const cellSizes = [
|
|
30
|
+
dimensions[0] > 0 ? size[0] / dimensions[0] : 1,
|
|
31
|
+
dimensions[1] > 0 ? size[1] / dimensions[1] : 1,
|
|
32
|
+
dimensions[2] > 0 ? size[2] / dimensions[2] : 1
|
|
33
|
+
];
|
|
34
|
+
if (quads.length === 0) {
|
|
74
35
|
return {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
36
|
+
positions: new Float32Array(0),
|
|
37
|
+
normals: new Float32Array(0),
|
|
38
|
+
uvs: new Float32Array(0),
|
|
39
|
+
indices: new Uint32Array(0),
|
|
40
|
+
groups: [],
|
|
41
|
+
stats: {
|
|
42
|
+
voxels: voxels.filter((value) => value !== 0).length,
|
|
43
|
+
faces: 0
|
|
44
|
+
}
|
|
84
45
|
};
|
|
46
|
+
}
|
|
47
|
+
const positions = [];
|
|
48
|
+
const normals = [];
|
|
49
|
+
const uvs = [];
|
|
50
|
+
const indices = [];
|
|
51
|
+
const groups = [];
|
|
52
|
+
const pushQuad = (quad) => {
|
|
53
|
+
const baseIndex = positions.length / 3;
|
|
54
|
+
const axis = quad.axis;
|
|
55
|
+
const uAxis = (axis + 1) % 3;
|
|
56
|
+
const vAxis = (axis + 2) % 3;
|
|
57
|
+
const width = quad.size[0];
|
|
58
|
+
const height = quad.size[1];
|
|
59
|
+
const base = [quad.origin[0], quad.origin[1], quad.origin[2]];
|
|
60
|
+
base[axis] = quad.plane;
|
|
61
|
+
const corners = quad.normal === 1 ? [
|
|
62
|
+
[0, 0],
|
|
63
|
+
[width, 0],
|
|
64
|
+
[width, height],
|
|
65
|
+
[0, height]
|
|
66
|
+
] : [
|
|
67
|
+
[0, 0],
|
|
68
|
+
[0, height],
|
|
69
|
+
[width, height],
|
|
70
|
+
[width, 0]
|
|
71
|
+
];
|
|
72
|
+
const normalVector = [0, 0, 0];
|
|
73
|
+
normalVector[axis] = quad.normal;
|
|
74
|
+
corners.forEach(([uOffset, vOffset]) => {
|
|
75
|
+
const vertex = [base[0], base[1], base[2]];
|
|
76
|
+
vertex[uAxis] = base[uAxis] + uOffset;
|
|
77
|
+
vertex[vAxis] = base[vAxis] + vOffset;
|
|
78
|
+
positions.push(vertex[0] * cellSizes[0] - halfSize[0], vertex[1] * cellSizes[1] - halfSize[1], vertex[2] * cellSizes[2] - halfSize[2]);
|
|
79
|
+
normals.push(normalVector[0], normalVector[1], normalVector[2]);
|
|
80
|
+
const u = width > 0 ? uOffset / width : 0;
|
|
81
|
+
const v = height > 0 ? vOffset / height : 0;
|
|
82
|
+
uvs.push(u, v);
|
|
83
|
+
});
|
|
84
|
+
const startIndex = indices.length;
|
|
85
|
+
indices.push(baseIndex, baseIndex + 1, baseIndex + 2, baseIndex, baseIndex + 2, baseIndex + 3);
|
|
86
|
+
const lastGroup = groups[groups.length - 1];
|
|
87
|
+
if (lastGroup && lastGroup.material === quad.material && lastGroup.start + lastGroup.count === startIndex) {
|
|
88
|
+
lastGroup.count += 6;
|
|
89
|
+
} else {
|
|
90
|
+
groups.push({ material: quad.material, start: startIndex, count: 6 });
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
quads.forEach(pushQuad);
|
|
94
|
+
return {
|
|
95
|
+
positions: Float32Array.from(positions),
|
|
96
|
+
normals: Float32Array.from(normals),
|
|
97
|
+
uvs: Float32Array.from(uvs),
|
|
98
|
+
indices: Uint32Array.from(indices),
|
|
99
|
+
groups,
|
|
100
|
+
stats: {
|
|
101
|
+
voxels: voxels.filter((value) => value !== 0).length,
|
|
102
|
+
faces: quads.length
|
|
103
|
+
}
|
|
104
|
+
};
|
|
85
105
|
}
|
|
86
|
-
|
|
87
|
-
|
|
106
|
+
function hasVoxelData(primitive) {
|
|
107
|
+
return Array.isArray(primitive.voxels) && primitive.voxels.length > 0;
|
|
88
108
|
}
|
|
109
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
110
|
+
0 && (module.exports = {
|
|
111
|
+
buildVoxelMesh,
|
|
112
|
+
hasVoxelData
|
|
113
|
+
});
|
|
@@ -1,116 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var import_node_test = __toESM(require("node:test"));
|
|
24
|
+
var import_strict = __toESM(require("node:assert/strict"));
|
|
25
|
+
var import_node_path = __toESM(require("node:path"));
|
|
26
|
+
var import_node_url = require("node:url");
|
|
27
|
+
const import_meta = {};
|
|
28
|
+
const HERE = import_node_path.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
29
|
+
const WORKER_ENTRY = import_node_path.default.resolve(HERE, "fixtures/render-worker.js");
|
|
7
30
|
async function bundleEntityWorker() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
const { build } = await import("esbuild");
|
|
32
|
+
const result = await build({
|
|
33
|
+
entryPoints: [WORKER_ENTRY],
|
|
34
|
+
bundle: true,
|
|
35
|
+
platform: "browser",
|
|
36
|
+
format: "esm",
|
|
37
|
+
target: "es2022",
|
|
38
|
+
write: false,
|
|
39
|
+
sourcemap: false,
|
|
40
|
+
logLevel: "silent"
|
|
41
|
+
});
|
|
42
|
+
const output = result.outputFiles?.[0]?.text;
|
|
43
|
+
if (!output) {
|
|
44
|
+
throw new Error("failed_to_bundle_entity_worker");
|
|
45
|
+
}
|
|
46
|
+
return output;
|
|
24
47
|
}
|
|
25
48
|
function createPlaywrightLaunchError(tool, error) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
const message = error && typeof error === "object" && "message" in error ? String(error.message) : String(error);
|
|
50
|
+
if (/browserType\.launch/i.test(message) || /MachPortRendezvousServer/i.test(message)) {
|
|
51
|
+
return new Error([
|
|
52
|
+
`[${tool}] Failed to launch Playwright Chromium.`,
|
|
53
|
+
"",
|
|
54
|
+
"Required setup:",
|
|
55
|
+
" 1. npx playwright install chromium",
|
|
56
|
+
' 2. On macOS: xattr -dr com.apple.quarantine "$HOME/Library/Caches/ms-playwright"',
|
|
57
|
+
"",
|
|
58
|
+
`Original error: ${message}`
|
|
59
|
+
].join("\n"));
|
|
60
|
+
}
|
|
61
|
+
return error instanceof Error ? error : new Error(message);
|
|
39
62
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
63
|
+
(0, import_node_test.default)("renderBoxelToDataURL produces a PNG data URL", async (t) => {
|
|
64
|
+
const { chromium } = await import("playwright-core");
|
|
65
|
+
const bundle = await bundleEntityWorker();
|
|
66
|
+
let browser = null;
|
|
67
|
+
try {
|
|
68
|
+
browser = await chromium.launch({ headless: true, args: ["--no-sandbox"], chromiumSandbox: false });
|
|
69
|
+
} catch (error) {
|
|
70
|
+
const launchError = createPlaywrightLaunchError("boxel-three-test", error);
|
|
71
|
+
t.skip(launchError.message);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const page = await browser.newPage({ viewport: { width: 512, height: 512 } });
|
|
75
|
+
const consoleErrors = [];
|
|
76
|
+
page.on("console", (message) => {
|
|
77
|
+
if (message.type() === "error") {
|
|
78
|
+
consoleErrors.push(message.text());
|
|
46
79
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
page.
|
|
55
|
-
|
|
56
|
-
|
|
80
|
+
});
|
|
81
|
+
page.on("pageerror", (error) => {
|
|
82
|
+
consoleErrors.push(error?.message ?? String(error));
|
|
83
|
+
});
|
|
84
|
+
try {
|
|
85
|
+
await page.setContent('<canvas id="viewport"></canvas>', { waitUntil: "domcontentloaded" });
|
|
86
|
+
await page.addScriptTag({ type: "module", content: bundle });
|
|
87
|
+
await page.waitForFunction(() => typeof window.boxelExport !== "undefined");
|
|
88
|
+
const minimalEntity = {
|
|
89
|
+
id: "render-test",
|
|
90
|
+
geometry: {
|
|
91
|
+
id: "geom",
|
|
92
|
+
root: {
|
|
93
|
+
id: "Root",
|
|
94
|
+
position: [0, 0, 0],
|
|
95
|
+
children: [
|
|
96
|
+
{
|
|
97
|
+
id: "Node",
|
|
98
|
+
position: [0, 0.5, 0],
|
|
99
|
+
mesh: "box",
|
|
100
|
+
children: []
|
|
101
|
+
}
|
|
102
|
+
]
|
|
57
103
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
await page.waitForFunction(() => typeof window.boxelExport !== 'undefined');
|
|
66
|
-
const minimalEntity = {
|
|
67
|
-
id: 'render-test',
|
|
68
|
-
geometry: {
|
|
69
|
-
id: 'geom',
|
|
70
|
-
root: {
|
|
71
|
-
id: 'Root',
|
|
72
|
-
position: [0, 0, 0],
|
|
73
|
-
children: [
|
|
74
|
-
{
|
|
75
|
-
id: 'Node',
|
|
76
|
-
position: [0, 0.5, 0],
|
|
77
|
-
mesh: 'box',
|
|
78
|
-
children: [],
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
primitives: [
|
|
84
|
-
{
|
|
85
|
-
id: 'box',
|
|
86
|
-
kind: 'plain_box',
|
|
87
|
-
size: [1, 1, 1],
|
|
88
|
-
material: 'mat',
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
materials: [{ id: 'mat', baseColor: [200, 120, 60] }],
|
|
92
|
-
textures: [],
|
|
93
|
-
patterns: [],
|
|
94
|
-
animations: [],
|
|
95
|
-
};
|
|
96
|
-
const dataUrl = await page.evaluate(model => window.boxelExport.renderBoxel(model, {
|
|
97
|
-
mode: 'hierarchical',
|
|
98
|
-
width: 512,
|
|
99
|
-
height: 512,
|
|
100
|
-
direction: 'preview',
|
|
101
|
-
animationIds: null,
|
|
102
|
-
}), minimalEntity);
|
|
103
|
-
assert.strictEqual(typeof dataUrl, 'string');
|
|
104
|
-
assert.ok(dataUrl.startsWith('data:image/png;base64,'), 'Render output is not a PNG data URL');
|
|
105
|
-
assert.ok(dataUrl.length > 'data:image/png;base64,'.length, 'Render output is empty');
|
|
106
|
-
if (consoleErrors.length > 0) {
|
|
107
|
-
throw new Error(consoleErrors.join('\n'));
|
|
104
|
+
},
|
|
105
|
+
primitives: [
|
|
106
|
+
{
|
|
107
|
+
id: "box",
|
|
108
|
+
kind: "plain_box",
|
|
109
|
+
size: [1, 1, 1],
|
|
110
|
+
material: "mat"
|
|
108
111
|
}
|
|
112
|
+
],
|
|
113
|
+
materials: [{ id: "mat", baseColor: [200, 120, 60] }],
|
|
114
|
+
textures: [],
|
|
115
|
+
patterns: [],
|
|
116
|
+
animations: []
|
|
117
|
+
};
|
|
118
|
+
const dataUrl = await page.evaluate((model) => window.boxelExport.renderBoxel(model, {
|
|
119
|
+
mode: "hierarchical",
|
|
120
|
+
width: 512,
|
|
121
|
+
height: 512,
|
|
122
|
+
direction: "preview",
|
|
123
|
+
animationIds: null
|
|
124
|
+
}), minimalEntity);
|
|
125
|
+
import_strict.default.strictEqual(typeof dataUrl, "string");
|
|
126
|
+
import_strict.default.ok(dataUrl.startsWith("data:image/png;base64,"), "Render output is not a PNG data URL");
|
|
127
|
+
import_strict.default.ok(dataUrl.length > "data:image/png;base64,".length, "Render output is empty");
|
|
128
|
+
if (consoleErrors.length > 0) {
|
|
129
|
+
throw new Error(consoleErrors.join("\n"));
|
|
109
130
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
131
|
+
} finally {
|
|
132
|
+
await page.close();
|
|
133
|
+
if (browser) {
|
|
134
|
+
await browser.close();
|
|
115
135
|
}
|
|
136
|
+
}
|
|
116
137
|
});
|
|
@@ -1,63 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var THREE = __toESM(require("three"));
|
|
24
|
+
var import_GLTFExporter = require("three/examples/jsm/exporters/GLTFExporter.js");
|
|
25
|
+
var import_src = require("../../src/index.js");
|
|
26
|
+
var import_boxel_core = require("@playdrop/boxel-core");
|
|
5
27
|
function arrayBufferToBase64(buffer) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
const bytes = new Uint8Array(buffer);
|
|
29
|
+
const chunkSize = 32768;
|
|
30
|
+
let binary = "";
|
|
31
|
+
for (let index = 0; index < bytes.length; index += chunkSize) {
|
|
32
|
+
const chunk = bytes.subarray(index, index + chunkSize);
|
|
33
|
+
binary += String.fromCharCode(...chunk);
|
|
34
|
+
}
|
|
35
|
+
return btoa(binary);
|
|
14
36
|
}
|
|
15
37
|
let cachedRenderer = null;
|
|
16
38
|
function getRenderer() {
|
|
17
|
-
|
|
18
|
-
return cachedRenderer;
|
|
19
|
-
}
|
|
20
|
-
const canvas = document.getElementById('viewport');
|
|
21
|
-
if (!canvas) {
|
|
22
|
-
throw new Error('render_canvas_unavailable');
|
|
23
|
-
}
|
|
24
|
-
cachedRenderer = new THREE.WebGLRenderer({
|
|
25
|
-
canvas,
|
|
26
|
-
antialias: true,
|
|
27
|
-
preserveDrawingBuffer: true,
|
|
28
|
-
alpha: true,
|
|
29
|
-
});
|
|
39
|
+
if (cachedRenderer) {
|
|
30
40
|
return cachedRenderer;
|
|
41
|
+
}
|
|
42
|
+
const canvas = document.getElementById("viewport");
|
|
43
|
+
if (!canvas) {
|
|
44
|
+
throw new Error("render_canvas_unavailable");
|
|
45
|
+
}
|
|
46
|
+
cachedRenderer = new THREE.WebGLRenderer({
|
|
47
|
+
canvas,
|
|
48
|
+
antialias: true,
|
|
49
|
+
preserveDrawingBuffer: true,
|
|
50
|
+
alpha: true
|
|
51
|
+
});
|
|
52
|
+
return cachedRenderer;
|
|
31
53
|
}
|
|
32
54
|
async function exportBoxel(modelJson, options) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
const model = (0, import_boxel_core.parseBoxel)(modelJson);
|
|
56
|
+
const blob = await (0, import_src.exportModelToGLB)({
|
|
57
|
+
THREE,
|
|
58
|
+
GLTFExporterCtor: import_GLTFExporter.GLTFExporter,
|
|
59
|
+
model,
|
|
60
|
+
mode: options?.mode,
|
|
61
|
+
animationIds: options?.animationIds
|
|
62
|
+
});
|
|
63
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
64
|
+
return arrayBufferToBase64(arrayBuffer);
|
|
43
65
|
}
|
|
44
66
|
async function renderBoxel(modelJson, options) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
const model = (0, import_boxel_core.parseBoxel)(modelJson);
|
|
68
|
+
const renderer = getRenderer();
|
|
69
|
+
renderer.setPixelRatio(1);
|
|
70
|
+
return (0, import_src.renderBoxelToDataURL)({
|
|
71
|
+
THREE,
|
|
72
|
+
renderer,
|
|
73
|
+
entity: model,
|
|
74
|
+
mode: options?.mode ?? "hierarchical",
|
|
75
|
+
animationIds: options?.animationIds,
|
|
76
|
+
width: options?.width,
|
|
77
|
+
height: options?.height,
|
|
78
|
+
direction: options?.direction,
|
|
79
|
+
background: options?.background ?? null
|
|
80
|
+
});
|
|
59
81
|
}
|
|
60
82
|
window.boxelExport = {
|
|
61
|
-
|
|
62
|
-
|
|
83
|
+
exportBoxel,
|
|
84
|
+
renderBoxel
|
|
63
85
|
};
|