@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.
Files changed (70) hide show
  1. package/config/client-meta.json +1 -1
  2. package/node_modules/@playdrop/ai-client/dist/index.js +461 -444
  3. package/node_modules/@playdrop/ai-client/package.json +1 -1
  4. package/node_modules/@playdrop/api-client/dist/client.js +903 -882
  5. package/node_modules/@playdrop/api-client/dist/core/errors.js +69 -45
  6. package/node_modules/@playdrop/api-client/dist/core/request.js +188 -159
  7. package/node_modules/@playdrop/api-client/dist/domains/admin.js +516 -491
  8. package/node_modules/@playdrop/api-client/dist/domains/ai.js +40 -14
  9. package/node_modules/@playdrop/api-client/dist/domains/apps.js +480 -462
  10. package/node_modules/@playdrop/api-client/dist/domains/asset-packs.js +439 -419
  11. package/node_modules/@playdrop/api-client/dist/domains/assets.js +696 -676
  12. package/node_modules/@playdrop/api-client/dist/domains/auth.js +346 -320
  13. package/node_modules/@playdrop/api-client/dist/domains/comments.js +124 -98
  14. package/node_modules/@playdrop/api-client/dist/domains/free-credits.js +91 -65
  15. package/node_modules/@playdrop/api-client/dist/domains/me.js +71 -45
  16. package/node_modules/@playdrop/api-client/dist/domains/payments.js +407 -386
  17. package/node_modules/@playdrop/api-client/dist/domains/player-meta.js +144 -118
  18. package/node_modules/@playdrop/api-client/dist/domains/search.js +117 -104
  19. package/node_modules/@playdrop/api-client/dist/domains/tags.js +188 -162
  20. package/node_modules/@playdrop/api-client/dist/index.js +993 -552
  21. package/node_modules/@playdrop/api-client/package.json +1 -1
  22. package/node_modules/@playdrop/boxel-three/dist/src/animations.js +84 -62
  23. package/node_modules/@playdrop/boxel-three/dist/src/builders.js +341 -308
  24. package/node_modules/@playdrop/boxel-three/dist/src/context.js +55 -29
  25. package/node_modules/@playdrop/boxel-three/dist/src/exporters/glb.js +856 -858
  26. package/node_modules/@playdrop/boxel-three/dist/src/exporters/image.js +267 -261
  27. package/node_modules/@playdrop/boxel-three/dist/src/index.js +64 -15
  28. package/node_modules/@playdrop/boxel-three/dist/src/instantiate.js +89 -63
  29. package/node_modules/@playdrop/boxel-three/dist/src/nodes.js +81 -56
  30. package/node_modules/@playdrop/boxel-three/dist/src/overlays.js +112 -86
  31. package/node_modules/@playdrop/boxel-three/dist/src/primitives.js +45 -17
  32. package/node_modules/@playdrop/boxel-three/dist/src/scene.js +160 -136
  33. package/node_modules/@playdrop/boxel-three/dist/src/skinned-mesh.js +582 -584
  34. package/node_modules/@playdrop/boxel-three/dist/src/texture-atlas.js +123 -97
  35. package/node_modules/@playdrop/boxel-three/dist/src/textures.js +207 -182
  36. package/node_modules/@playdrop/boxel-three/dist/src/types.js +15 -1
  37. package/node_modules/@playdrop/boxel-three/dist/src/voxels/faces.js +451 -425
  38. package/node_modules/@playdrop/boxel-three/dist/src/voxels/mesher.js +109 -84
  39. package/node_modules/@playdrop/boxel-three/dist/test/export-image.playwright.test.js +127 -106
  40. package/node_modules/@playdrop/boxel-three/dist/test/fixtures/render-worker.js +73 -51
  41. package/node_modules/@playdrop/boxel-three/dist/test/glb-skinned.test.js +97 -79
  42. package/node_modules/@playdrop/boxel-three/dist/test/index.test.js +29 -7
  43. package/node_modules/@playdrop/boxel-three/dist/test/instantiate.test.js +80 -60
  44. package/node_modules/@playdrop/boxel-three/dist/test/overlays.test.js +41 -19
  45. package/node_modules/@playdrop/boxel-three/dist/test/scene-filter.test.js +72 -50
  46. package/node_modules/@playdrop/boxel-three/dist/test/scene-smoke.test.js +84 -62
  47. package/node_modules/@playdrop/boxel-three/dist/test/skinned-mesh.test.js +69 -47
  48. package/node_modules/@playdrop/boxel-three/dist/test/textured-overlay.test.js +129 -109
  49. package/node_modules/@playdrop/boxel-three/dist/test/voxels.test.js +40 -18
  50. package/node_modules/@playdrop/boxel-three/package.json +1 -1
  51. package/node_modules/@playdrop/config/client-meta.json +1 -1
  52. package/node_modules/@playdrop/types/dist/api.js +289 -203
  53. package/node_modules/@playdrop/types/dist/app-capability-filters.js +112 -62
  54. package/node_modules/@playdrop/types/dist/app.js +91 -45
  55. package/node_modules/@playdrop/types/dist/asset-pack.js +37 -5
  56. package/node_modules/@playdrop/types/dist/asset-spec.js +170 -90
  57. package/node_modules/@playdrop/types/dist/asset.js +186 -108
  58. package/node_modules/@playdrop/types/dist/content-license.js +49 -15
  59. package/node_modules/@playdrop/types/dist/creator-public-image.js +60 -32
  60. package/node_modules/@playdrop/types/dist/ecs.js +102 -82
  61. package/node_modules/@playdrop/types/dist/engine-builtins.js +603 -573
  62. package/node_modules/@playdrop/types/dist/entity.js +63 -53
  63. package/node_modules/@playdrop/types/dist/graph.js +116 -80
  64. package/node_modules/@playdrop/types/dist/index.js +47 -20
  65. package/node_modules/@playdrop/types/dist/owned-assets.js +55 -33
  66. package/node_modules/@playdrop/types/dist/player-meta.js +151 -100
  67. package/node_modules/@playdrop/types/dist/realtime.js +27 -7
  68. package/node_modules/@playdrop/types/dist/version.js +182 -124
  69. package/node_modules/@playdrop/types/package.json +1 -1
  70. package/package.json +1 -1
@@ -1,330 +1,363 @@
1
- import { resolveFaceTextureId, resolveOverlayFaceTextureId } from '@playdrop/boxel-core';
2
- import { createBoxGeometry } from './primitives.js';
3
- import { createTextureMaterial, toThreeColorRGB } from './textures.js';
4
- import { buildVoxelMesh } from './voxels/mesher.js';
5
- export const DEFAULT_COLOR = 0x3b82f6;
6
- export const DEFAULT_OPACITY = 0.45;
7
- export const DEFAULT_WIREFRAME_COLOR = 0x60a5fa;
8
- const BOX_FACES = ['east', 'west', 'top', 'bottom', 'north', 'south'];
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 builders_exports = {};
19
+ __export(builders_exports, {
20
+ DEFAULT_COLOR: () => DEFAULT_COLOR,
21
+ DEFAULT_OPACITY: () => DEFAULT_OPACITY,
22
+ DEFAULT_WIREFRAME_COLOR: () => DEFAULT_WIREFRAME_COLOR,
23
+ createBoundingBoxMesh: () => createBoundingBoxMesh,
24
+ createPrimitiveObject: () => createPrimitiveObject
25
+ });
26
+ module.exports = __toCommonJS(builders_exports);
27
+ var import_boxel_core = require("@playdrop/boxel-core");
28
+ var import_primitives = require("./primitives.js");
29
+ var import_textures = require("./textures.js");
30
+ var import_mesher = require("./voxels/mesher.js");
31
+ const DEFAULT_COLOR = 3900150;
32
+ const DEFAULT_OPACITY = 0.45;
33
+ const DEFAULT_WIREFRAME_COLOR = 6333946;
34
+ const BOX_FACES = ["east", "west", "top", "bottom", "north", "south"];
9
35
  const OVERLAY_THICKNESS = 0.25;
10
- export function createBoundingBoxMesh(context, size) {
11
- const geometry = createBoxGeometry(context.THREE, size);
12
- const material = new context.THREE.MeshStandardMaterial({
13
- color: DEFAULT_COLOR,
14
- transparent: true,
15
- opacity: DEFAULT_OPACITY,
16
- metalness: 0,
17
- roughness: 0.75,
18
- });
19
- const mesh = new context.THREE.Mesh(geometry, material);
20
- const edges = new context.THREE.EdgesGeometry(geometry);
21
- const lineMaterial = new context.THREE.LineBasicMaterial({ color: DEFAULT_WIREFRAME_COLOR });
22
- const wireframe = new context.THREE.LineSegments(edges, lineMaterial);
23
- mesh.add(wireframe);
24
- mesh.userData = {
25
- ...(mesh.userData ?? {}),
26
- size: [...size],
27
- placeholder: true,
28
- };
29
- return mesh;
36
+ function createBoundingBoxMesh(context, size) {
37
+ const geometry = (0, import_primitives.createBoxGeometry)(context.THREE, size);
38
+ const material = new context.THREE.MeshStandardMaterial({
39
+ color: DEFAULT_COLOR,
40
+ transparent: true,
41
+ opacity: DEFAULT_OPACITY,
42
+ metalness: 0,
43
+ roughness: 0.75
44
+ });
45
+ const mesh = new context.THREE.Mesh(geometry, material);
46
+ const edges = new context.THREE.EdgesGeometry(geometry);
47
+ const lineMaterial = new context.THREE.LineBasicMaterial({ color: DEFAULT_WIREFRAME_COLOR });
48
+ const wireframe = new context.THREE.LineSegments(edges, lineMaterial);
49
+ mesh.add(wireframe);
50
+ mesh.userData = {
51
+ ...mesh.userData ?? {},
52
+ size: [...size],
53
+ placeholder: true
54
+ };
55
+ return mesh;
30
56
  }
31
57
  function createPlainBoxObject(context, primitive, alignment) {
32
- const materialDef = context.materialsById.get(primitive.material);
33
- const color = materialDef?.baseColor ?? [59, 130, 246];
34
- const geometry = createBoxGeometry(context.THREE, primitive.size);
35
- const meshMaterial = new context.THREE.MeshStandardMaterial({
36
- color: toThreeColorRGB(context, color),
37
- metalness: 0,
38
- roughness: 1,
39
- transparent: materialDef?.opacity !== undefined && materialDef.opacity < 1,
40
- opacity: materialDef?.opacity !== undefined ? materialDef.opacity : 1,
41
- });
42
- if (materialDef?.emissiveColor) {
43
- meshMaterial.emissive.copy(toThreeColorRGB(context, materialDef.emissiveColor));
44
- meshMaterial.emissiveIntensity = 1;
45
- }
46
- meshMaterial.needsUpdate = true;
47
- const mesh = new context.THREE.Mesh(geometry, meshMaterial);
48
- mesh.name = primitive.id;
49
- mesh.userData = {
50
- ...(mesh.userData ?? {}),
51
- primitiveId: primitive.id,
52
- size: [...primitive.size],
53
- };
54
- if (alignment === 'grounded') {
55
- mesh.position.y = primitive.size[1] / 2;
56
- }
57
- return mesh;
58
+ const materialDef = context.materialsById.get(primitive.material);
59
+ const color = materialDef?.baseColor ?? [59, 130, 246];
60
+ const geometry = (0, import_primitives.createBoxGeometry)(context.THREE, primitive.size);
61
+ const meshMaterial = new context.THREE.MeshStandardMaterial({
62
+ color: (0, import_textures.toThreeColorRGB)(context, color),
63
+ metalness: 0,
64
+ roughness: 1,
65
+ transparent: materialDef?.opacity !== void 0 && materialDef.opacity < 1,
66
+ opacity: materialDef?.opacity !== void 0 ? materialDef.opacity : 1
67
+ });
68
+ if (materialDef?.emissiveColor) {
69
+ meshMaterial.emissive.copy((0, import_textures.toThreeColorRGB)(context, materialDef.emissiveColor));
70
+ meshMaterial.emissiveIntensity = 1;
71
+ }
72
+ meshMaterial.needsUpdate = true;
73
+ const mesh = new context.THREE.Mesh(geometry, meshMaterial);
74
+ mesh.name = primitive.id;
75
+ mesh.userData = {
76
+ ...mesh.userData ?? {},
77
+ primitiveId: primitive.id,
78
+ size: [...primitive.size]
79
+ };
80
+ if (alignment === "grounded") {
81
+ mesh.position.y = primitive.size[1] / 2;
82
+ }
83
+ return mesh;
58
84
  }
59
85
  function createTexturedBoxObject(context, primitive, alignment) {
60
- const geometry = createBoxGeometry(context.THREE, primitive.size);
61
- const materials = BOX_FACES.map(face => createTextureMaterial(context, resolveFaceTextureId(primitive, face)));
62
- const renderMode = primitive.renderMode === 'cutout' ? 'cutout' : 'plain';
63
- materials.forEach(material => {
64
- if (renderMode === 'cutout') {
65
- material.transparent = false;
66
- material.alphaTest = 0.5;
67
- material.side = context.THREE.DoubleSide;
68
- }
69
- else {
70
- material.transparent = true;
71
- material.alphaTest = 0;
72
- material.side = context.THREE.FrontSide;
73
- }
74
- material.depthWrite = true;
75
- material.needsUpdate = true;
76
- });
77
- const mesh = new context.THREE.Mesh(geometry, materials);
78
- mesh.name = primitive.id;
79
- mesh.userData = {
80
- ...(mesh.userData ?? {}),
81
- primitiveId: primitive.id,
82
- size: [...primitive.size],
83
- };
84
- if (alignment === 'grounded') {
85
- mesh.position.y = primitive.size[1] / 2;
86
+ const geometry = (0, import_primitives.createBoxGeometry)(context.THREE, primitive.size);
87
+ const materials = BOX_FACES.map((face) => (0, import_textures.createTextureMaterial)(context, (0, import_boxel_core.resolveFaceTextureId)(primitive, face)));
88
+ const renderMode = primitive.renderMode === "cutout" ? "cutout" : "plain";
89
+ materials.forEach((material) => {
90
+ if (renderMode === "cutout") {
91
+ material.transparent = false;
92
+ material.alphaTest = 0.5;
93
+ material.side = context.THREE.DoubleSide;
94
+ } else {
95
+ material.transparent = true;
96
+ material.alphaTest = 0;
97
+ material.side = context.THREE.FrontSide;
86
98
  }
87
- const overlayTextureIds = BOX_FACES.map(face => resolveOverlayFaceTextureId(primitive, face));
88
- const hasOverlay = overlayTextureIds.some(id => typeof id === 'string' && id.trim().length > 0);
89
- if (hasOverlay) {
90
- const overlaySize = [
91
- primitive.size[0] + OVERLAY_THICKNESS * 2,
92
- primitive.size[1] + OVERLAY_THICKNESS * 2,
93
- primitive.size[2] + OVERLAY_THICKNESS * 2,
94
- ];
95
- const overlayGeometry = createBoxGeometry(context.THREE, overlaySize);
96
- const overlayMaterials = overlayTextureIds.map(textureId => {
97
- if (!textureId) {
98
- const emptyMaterial = new context.THREE.MeshStandardMaterial({
99
- transparent: true,
100
- opacity: 0,
101
- depthWrite: false,
102
- metalness: 0,
103
- roughness: 1,
104
- });
105
- emptyMaterial.visible = false;
106
- emptyMaterial.needsUpdate = true;
107
- return emptyMaterial;
108
- }
109
- const material = createTextureMaterial(context, textureId);
110
- material.transparent = true;
111
- material.alphaTest = 0.5;
112
- material.side = context.THREE.DoubleSide;
113
- material.depthWrite = false;
114
- material.needsUpdate = true;
115
- return material;
99
+ material.depthWrite = true;
100
+ material.needsUpdate = true;
101
+ });
102
+ const mesh = new context.THREE.Mesh(geometry, materials);
103
+ mesh.name = primitive.id;
104
+ mesh.userData = {
105
+ ...mesh.userData ?? {},
106
+ primitiveId: primitive.id,
107
+ size: [...primitive.size]
108
+ };
109
+ if (alignment === "grounded") {
110
+ mesh.position.y = primitive.size[1] / 2;
111
+ }
112
+ const overlayTextureIds = BOX_FACES.map((face) => (0, import_boxel_core.resolveOverlayFaceTextureId)(primitive, face));
113
+ const hasOverlay = overlayTextureIds.some((id) => typeof id === "string" && id.trim().length > 0);
114
+ if (hasOverlay) {
115
+ const overlaySize = [
116
+ primitive.size[0] + OVERLAY_THICKNESS * 2,
117
+ primitive.size[1] + OVERLAY_THICKNESS * 2,
118
+ primitive.size[2] + OVERLAY_THICKNESS * 2
119
+ ];
120
+ const overlayGeometry = (0, import_primitives.createBoxGeometry)(context.THREE, overlaySize);
121
+ const overlayMaterials = overlayTextureIds.map((textureId) => {
122
+ if (!textureId) {
123
+ const emptyMaterial = new context.THREE.MeshStandardMaterial({
124
+ transparent: true,
125
+ opacity: 0,
126
+ depthWrite: false,
127
+ metalness: 0,
128
+ roughness: 1
116
129
  });
117
- const overlayMesh = new context.THREE.Mesh(overlayGeometry, overlayMaterials);
118
- overlayMesh.name = `${primitive.id}_overlay`;
119
- overlayMesh.renderOrder = mesh.renderOrder + 1;
120
- overlayMesh.userData = {
121
- ...(mesh.userData ?? {}),
122
- primitiveId: primitive.id,
123
- overlay: true,
124
- size: [...overlaySize],
125
- };
126
- mesh.add(overlayMesh);
127
- }
128
- return mesh;
130
+ emptyMaterial.visible = false;
131
+ emptyMaterial.needsUpdate = true;
132
+ return emptyMaterial;
133
+ }
134
+ const material = (0, import_textures.createTextureMaterial)(context, textureId);
135
+ material.transparent = true;
136
+ material.alphaTest = 0.5;
137
+ material.side = context.THREE.DoubleSide;
138
+ material.depthWrite = false;
139
+ material.needsUpdate = true;
140
+ return material;
141
+ });
142
+ const overlayMesh = new context.THREE.Mesh(overlayGeometry, overlayMaterials);
143
+ overlayMesh.name = `${primitive.id}_overlay`;
144
+ overlayMesh.renderOrder = mesh.renderOrder + 1;
145
+ overlayMesh.userData = {
146
+ ...mesh.userData ?? {},
147
+ primitiveId: primitive.id,
148
+ overlay: true,
149
+ size: [...overlaySize]
150
+ };
151
+ mesh.add(overlayMesh);
152
+ }
153
+ return mesh;
129
154
  }
130
155
  function createVoxelObject(context, primitive, alignment) {
131
- const hasData = Array.isArray(primitive.voxels) && primitive.voxels.length > 0;
132
- const size = primitive.size ?? [1, 1, 1];
133
- const dims = [
134
- Math.max(1, Math.round(size[0])),
135
- Math.max(1, Math.round(size[1])),
136
- Math.max(1, Math.round(size[2])),
137
- ];
138
- const worldSize = [dims[0], dims[1], dims[2]];
139
- if (!hasData) {
140
- const mesh = createBoundingBoxMesh(context, worldSize);
141
- mesh.userData = {
142
- ...(mesh.userData ?? {}),
143
- primitiveId: primitive.id,
144
- size: [...worldSize],
145
- };
146
- if (alignment === 'grounded') {
147
- mesh.position.y = worldSize[1] / 2;
148
- }
149
- return mesh;
156
+ const hasData = Array.isArray(primitive.voxels) && primitive.voxels.length > 0;
157
+ const size = primitive.size ?? [1, 1, 1];
158
+ const dims = [
159
+ Math.max(1, Math.round(size[0])),
160
+ Math.max(1, Math.round(size[1])),
161
+ Math.max(1, Math.round(size[2]))
162
+ ];
163
+ const worldSize = [dims[0], dims[1], dims[2]];
164
+ if (!hasData) {
165
+ const mesh2 = createBoundingBoxMesh(context, worldSize);
166
+ mesh2.userData = {
167
+ ...mesh2.userData ?? {},
168
+ primitiveId: primitive.id,
169
+ size: [...worldSize]
170
+ };
171
+ if (alignment === "grounded") {
172
+ mesh2.position.y = worldSize[1] / 2;
150
173
  }
151
- const meshResult = buildVoxelMesh({
152
- voxels: primitive.voxels,
153
- dimensions: dims,
154
- size: worldSize,
155
- });
156
- if (meshResult.indices.length === 0 || meshResult.positions.length === 0) {
157
- const mesh = createBoundingBoxMesh(context, worldSize);
158
- mesh.userData = {
159
- ...(mesh.userData ?? {}),
160
- primitiveId: primitive.id,
161
- size: [...worldSize],
162
- };
163
- if (alignment === 'grounded') {
164
- mesh.position.y = worldSize[1] / 2;
165
- }
166
- return mesh;
174
+ return mesh2;
175
+ }
176
+ const meshResult = (0, import_mesher.buildVoxelMesh)({
177
+ voxels: primitive.voxels,
178
+ dimensions: dims,
179
+ size: worldSize
180
+ });
181
+ if (meshResult.indices.length === 0 || meshResult.positions.length === 0) {
182
+ const mesh2 = createBoundingBoxMesh(context, worldSize);
183
+ mesh2.userData = {
184
+ ...mesh2.userData ?? {},
185
+ primitiveId: primitive.id,
186
+ size: [...worldSize]
187
+ };
188
+ if (alignment === "grounded") {
189
+ mesh2.position.y = worldSize[1] / 2;
167
190
  }
168
- const paletteIds = primitive.palette ?? [];
169
- const materialCache = new Map();
170
- const materialIndexMap = new Map();
171
- const materials = [];
172
- const geometry = new context.THREE.BufferGeometry();
173
- geometry.setAttribute('position', new context.THREE.Float32BufferAttribute(meshResult.positions, 3));
174
- geometry.setAttribute('normal', new context.THREE.Float32BufferAttribute(meshResult.normals, 3));
175
- geometry.setAttribute('uv', new context.THREE.Float32BufferAttribute(meshResult.uvs, 2));
176
- if (meshResult.indices.length > 0) {
177
- const vertexCount = meshResult.positions.length / 3;
178
- const useUint32 = vertexCount > 65535;
179
- const indexArray = useUint32 ? meshResult.indices : new Uint16Array(meshResult.indices);
180
- geometry.setIndex(new context.THREE.BufferAttribute(indexArray, 1));
191
+ return mesh2;
192
+ }
193
+ const paletteIds = primitive.palette ?? [];
194
+ const materialCache = /* @__PURE__ */ new Map();
195
+ const materialIndexMap = /* @__PURE__ */ new Map();
196
+ const materials = [];
197
+ const geometry = new context.THREE.BufferGeometry();
198
+ geometry.setAttribute("position", new context.THREE.Float32BufferAttribute(meshResult.positions, 3));
199
+ geometry.setAttribute("normal", new context.THREE.Float32BufferAttribute(meshResult.normals, 3));
200
+ geometry.setAttribute("uv", new context.THREE.Float32BufferAttribute(meshResult.uvs, 2));
201
+ if (meshResult.indices.length > 0) {
202
+ const vertexCount = meshResult.positions.length / 3;
203
+ const useUint32 = vertexCount > 65535;
204
+ const indexArray = useUint32 ? meshResult.indices : new Uint16Array(meshResult.indices);
205
+ geometry.setIndex(new context.THREE.BufferAttribute(indexArray, 1));
206
+ }
207
+ geometry.computeBoundingBox();
208
+ geometry.computeBoundingSphere();
209
+ meshResult.groups.forEach((groupData) => {
210
+ const paletteIndex = groupData.material;
211
+ let material = materialCache.get(paletteIndex);
212
+ if (!material) {
213
+ const materialId = paletteIds[paletteIndex - 1];
214
+ const materialDef = materialId ? context.materialsById.get(materialId) : void 0;
215
+ const baseColor = materialDef?.baseColor ?? [59, 130, 246];
216
+ const emissive = materialDef?.emissiveColor;
217
+ const opacity = materialDef?.opacity ?? 1;
218
+ material = new context.THREE.MeshStandardMaterial({
219
+ color: (0, import_textures.toThreeColorRGB)(context, baseColor),
220
+ metalness: 0,
221
+ roughness: 1,
222
+ transparent: opacity < 1,
223
+ opacity
224
+ });
225
+ if (emissive) {
226
+ material.emissive.copy((0, import_textures.toThreeColorRGB)(context, emissive));
227
+ material.emissiveIntensity = 1;
228
+ }
229
+ material.needsUpdate = true;
230
+ materialCache.set(paletteIndex, material);
181
231
  }
182
- geometry.computeBoundingBox();
183
- geometry.computeBoundingSphere();
184
- meshResult.groups.forEach(groupData => {
185
- const paletteIndex = groupData.material;
186
- let material = materialCache.get(paletteIndex);
187
- if (!material) {
188
- const materialId = paletteIds[paletteIndex - 1];
189
- const materialDef = materialId ? context.materialsById.get(materialId) : undefined;
190
- const baseColor = materialDef?.baseColor ?? [59, 130, 246];
191
- const emissive = materialDef?.emissiveColor;
192
- const opacity = materialDef?.opacity ?? 1;
193
- material = new context.THREE.MeshStandardMaterial({
194
- color: toThreeColorRGB(context, baseColor),
195
- metalness: 0,
196
- roughness: 1,
197
- transparent: opacity < 1,
198
- opacity,
199
- });
200
- if (emissive) {
201
- material.emissive.copy(toThreeColorRGB(context, emissive));
202
- material.emissiveIntensity = 1;
203
- }
204
- material.needsUpdate = true;
205
- materialCache.set(paletteIndex, material);
206
- }
207
- let materialIndex = materialIndexMap.get(paletteIndex);
208
- if (materialIndex === undefined) {
209
- materialIndex = materials.length;
210
- materials.push(material);
211
- materialIndexMap.set(paletteIndex, materialIndex);
212
- }
213
- geometry.addGroup(groupData.start, groupData.count, materialIndex);
214
- });
215
- const meshMaterial = materials.length === 1 ? materials[0] : materials;
216
- const mesh = new context.THREE.Mesh(geometry, meshMaterial);
217
- mesh.name = primitive.id;
218
- mesh.userData = {
219
- ...(mesh.userData ?? {}),
220
- primitiveId: primitive.id,
221
- size: [...worldSize],
222
- };
223
- if (alignment === 'grounded') {
224
- mesh.position.y = size[1] / 2;
232
+ let materialIndex = materialIndexMap.get(paletteIndex);
233
+ if (materialIndex === void 0) {
234
+ materialIndex = materials.length;
235
+ materials.push(material);
236
+ materialIndexMap.set(paletteIndex, materialIndex);
225
237
  }
226
- return mesh;
238
+ geometry.addGroup(groupData.start, groupData.count, materialIndex);
239
+ });
240
+ const meshMaterial = materials.length === 1 ? materials[0] : materials;
241
+ const mesh = new context.THREE.Mesh(geometry, meshMaterial);
242
+ mesh.name = primitive.id;
243
+ mesh.userData = {
244
+ ...mesh.userData ?? {},
245
+ primitiveId: primitive.id,
246
+ size: [...worldSize]
247
+ };
248
+ if (alignment === "grounded") {
249
+ mesh.position.y = size[1] / 2;
250
+ }
251
+ return mesh;
227
252
  }
228
253
  function createComboObject(context, primitive, alignment, visited) {
229
- const group = new context.THREE.Group();
230
- group.name = primitive.id;
231
- const sockets = [];
232
- const slotEntries = [];
233
- primitive.slots.forEach(slot => {
234
- const childPrimitive = context.primitivesById.get(slot.primitive);
235
- if (!childPrimitive) {
236
- console.warn('[boxel-three] combo slot references missing primitive', slot.primitive);
237
- return;
238
- }
239
- const object = createPrimitiveObject(context, childPrimitive, alignment, new Set(visited));
240
- if (!object)
241
- return;
242
- const childSize = [
243
- childPrimitive.size?.[0] ?? 0,
244
- childPrimitive.size?.[1] ?? 0,
245
- childPrimitive.size?.[2] ?? 0,
246
- ];
247
- slotEntries.push({ slot, object, size: childSize });
248
- });
249
- if (slotEntries.length === 0) {
250
- const fallbackSize = [
251
- primitive.size?.[0] ?? 1,
252
- primitive.size?.[1] ?? 1,
253
- primitive.size?.[2] ?? 1,
254
- ];
255
- const bounding = createBoundingBoxMesh(context, fallbackSize);
256
- bounding.userData = {
257
- ...(bounding.userData ?? {}),
258
- primitiveId: primitive.id,
259
- size: [...fallbackSize],
260
- };
261
- if (alignment === 'grounded') {
262
- bounding.position.y = fallbackSize[1] / 2;
263
- }
264
- return bounding;
254
+ const group = new context.THREE.Group();
255
+ group.name = primitive.id;
256
+ const sockets = [];
257
+ const slotEntries = [];
258
+ primitive.slots.forEach((slot) => {
259
+ const childPrimitive = context.primitivesById.get(slot.primitive);
260
+ if (!childPrimitive) {
261
+ console.warn("[boxel-three] combo slot references missing primitive", slot.primitive);
262
+ return;
265
263
  }
266
- let minX = Infinity;
267
- let minY = Infinity;
268
- let minZ = Infinity;
269
- let maxX = -Infinity;
270
- let maxY = -Infinity;
271
- let maxZ = -Infinity;
272
- slotEntries.forEach(({ slot, size }) => {
273
- const halfSize = [size[0] / 2, size[1] / 2, size[2] / 2];
274
- minX = Math.min(minX, slot.offset[0] - halfSize[0]);
275
- minY = Math.min(minY, slot.offset[1] - halfSize[1]);
276
- minZ = Math.min(minZ, slot.offset[2] - halfSize[2]);
277
- maxX = Math.max(maxX, slot.offset[0] + halfSize[0]);
278
- maxY = Math.max(maxY, slot.offset[1] + halfSize[1]);
279
- maxZ = Math.max(maxZ, slot.offset[2] + halfSize[2]);
280
- });
281
- const derivedSize = [
282
- Math.max(0, maxX - minX),
283
- Math.max(0, maxY - minY),
284
- Math.max(0, maxZ - minZ),
264
+ const object = createPrimitiveObject(context, childPrimitive, alignment, new Set(visited));
265
+ if (!object)
266
+ return;
267
+ const childSize = [
268
+ childPrimitive.size?.[0] ?? 0,
269
+ childPrimitive.size?.[1] ?? 0,
270
+ childPrimitive.size?.[2] ?? 0
285
271
  ];
286
- slotEntries.forEach(({ slot, object }) => {
287
- object.position.set(slot.offset[0], slot.offset[1], slot.offset[2]);
288
- object.userData = {
289
- ...(object.userData ?? {}),
290
- comboSlotId: slot.id,
291
- comboParentId: primitive.id,
292
- };
293
- group.add(object);
294
- sockets.push([slot.offset[0], slot.offset[1], slot.offset[2]]);
295
- });
296
- const comboSize = [
297
- primitive.size?.[0] ?? derivedSize[0],
298
- primitive.size?.[1] ?? derivedSize[1],
299
- primitive.size?.[2] ?? derivedSize[2],
272
+ slotEntries.push({ slot, object, size: childSize });
273
+ });
274
+ if (slotEntries.length === 0) {
275
+ const fallbackSize = [
276
+ primitive.size?.[0] ?? 1,
277
+ primitive.size?.[1] ?? 1,
278
+ primitive.size?.[2] ?? 1
300
279
  ];
301
- group.userData = {
302
- ...(group.userData ?? {}),
303
- primitiveId: primitive.id,
304
- size: [...comboSize],
305
- sockets,
280
+ const bounding = createBoundingBoxMesh(context, fallbackSize);
281
+ bounding.userData = {
282
+ ...bounding.userData ?? {},
283
+ primitiveId: primitive.id,
284
+ size: [...fallbackSize]
306
285
  };
307
- if (alignment === 'grounded') {
308
- group.position.y = comboSize[1] / 2;
286
+ if (alignment === "grounded") {
287
+ bounding.position.y = fallbackSize[1] / 2;
309
288
  }
310
- return group;
289
+ return bounding;
290
+ }
291
+ let minX = Infinity;
292
+ let minY = Infinity;
293
+ let minZ = Infinity;
294
+ let maxX = -Infinity;
295
+ let maxY = -Infinity;
296
+ let maxZ = -Infinity;
297
+ slotEntries.forEach(({ slot, size }) => {
298
+ const halfSize = [size[0] / 2, size[1] / 2, size[2] / 2];
299
+ minX = Math.min(minX, slot.offset[0] - halfSize[0]);
300
+ minY = Math.min(minY, slot.offset[1] - halfSize[1]);
301
+ minZ = Math.min(minZ, slot.offset[2] - halfSize[2]);
302
+ maxX = Math.max(maxX, slot.offset[0] + halfSize[0]);
303
+ maxY = Math.max(maxY, slot.offset[1] + halfSize[1]);
304
+ maxZ = Math.max(maxZ, slot.offset[2] + halfSize[2]);
305
+ });
306
+ const derivedSize = [
307
+ Math.max(0, maxX - minX),
308
+ Math.max(0, maxY - minY),
309
+ Math.max(0, maxZ - minZ)
310
+ ];
311
+ slotEntries.forEach(({ slot, object }) => {
312
+ object.position.set(slot.offset[0], slot.offset[1], slot.offset[2]);
313
+ object.userData = {
314
+ ...object.userData ?? {},
315
+ comboSlotId: slot.id,
316
+ comboParentId: primitive.id
317
+ };
318
+ group.add(object);
319
+ sockets.push([slot.offset[0], slot.offset[1], slot.offset[2]]);
320
+ });
321
+ const comboSize = [
322
+ primitive.size?.[0] ?? derivedSize[0],
323
+ primitive.size?.[1] ?? derivedSize[1],
324
+ primitive.size?.[2] ?? derivedSize[2]
325
+ ];
326
+ group.userData = {
327
+ ...group.userData ?? {},
328
+ primitiveId: primitive.id,
329
+ size: [...comboSize],
330
+ sockets
331
+ };
332
+ if (alignment === "grounded") {
333
+ group.position.y = comboSize[1] / 2;
334
+ }
335
+ return group;
311
336
  }
312
- export function createPrimitiveObject(context, primitive, alignment, visited = new Set()) {
313
- if (visited.has(primitive.id)) {
314
- console.warn('[boxel-three] detected recursive primitive reference', primitive.id);
315
- return null;
316
- }
317
- visited.add(primitive.id);
318
- switch (primitive.kind) {
319
- case 'plain_box':
320
- return createPlainBoxObject(context, primitive, alignment);
321
- case 'textured_box':
322
- return createTexturedBoxObject(context, primitive, alignment);
323
- case 'voxel_box':
324
- return createVoxelObject(context, primitive, alignment);
325
- case 'combo_box':
326
- return createComboObject(context, primitive, alignment, visited);
327
- default:
328
- return null;
329
- }
337
+ function createPrimitiveObject(context, primitive, alignment, visited = /* @__PURE__ */ new Set()) {
338
+ if (visited.has(primitive.id)) {
339
+ console.warn("[boxel-three] detected recursive primitive reference", primitive.id);
340
+ return null;
341
+ }
342
+ visited.add(primitive.id);
343
+ switch (primitive.kind) {
344
+ case "plain_box":
345
+ return createPlainBoxObject(context, primitive, alignment);
346
+ case "textured_box":
347
+ return createTexturedBoxObject(context, primitive, alignment);
348
+ case "voxel_box":
349
+ return createVoxelObject(context, primitive, alignment);
350
+ case "combo_box":
351
+ return createComboObject(context, primitive, alignment, visited);
352
+ default:
353
+ return null;
354
+ }
330
355
  }
356
+ // Annotate the CommonJS export names for ESM import in node:
357
+ 0 && (module.exports = {
358
+ DEFAULT_COLOR,
359
+ DEFAULT_OPACITY,
360
+ DEFAULT_WIREFRAME_COLOR,
361
+ createBoundingBoxMesh,
362
+ createPrimitiveObject
363
+ });