@playdrop/playdrop-cli 0.7.13 → 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/config/dist/tsconfig.tsbuildinfo +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,107 +1,133 @@
|
|
|
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 texture_atlas_exports = {};
|
|
19
|
+
__export(texture_atlas_exports, {
|
|
20
|
+
buildEmissiveAtlas: () => buildEmissiveAtlas,
|
|
21
|
+
buildTextureAtlas: () => buildTextureAtlas
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(texture_atlas_exports);
|
|
1
24
|
const toPowerOfTwo = (value) => {
|
|
2
|
-
|
|
25
|
+
return 2 ** Math.ceil(Math.log2(Math.max(1, value)));
|
|
3
26
|
};
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
27
|
+
function buildTextureAtlas(THREE, textures) {
|
|
28
|
+
const uniqueTextures = Array.from(new Set(textures));
|
|
29
|
+
if (uniqueTextures.length === 0) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const maxWidth = uniqueTextures.reduce((acc, tex) => Math.max(acc, tex.image?.width ?? 0), 0);
|
|
33
|
+
const totalHeight = uniqueTextures.reduce((acc, tex) => acc + (tex.image?.height ?? 0), 0);
|
|
34
|
+
if (maxWidth === 0 || totalHeight === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const atlasWidth = toPowerOfTwo(maxWidth);
|
|
38
|
+
const atlasHeight = toPowerOfTwo(totalHeight);
|
|
39
|
+
const atlasData = new Uint8Array(atlasWidth * atlasHeight * 4);
|
|
40
|
+
const transforms = /* @__PURE__ */ new Map();
|
|
41
|
+
let offsetY = 0;
|
|
42
|
+
uniqueTextures.forEach((texture) => {
|
|
43
|
+
const image = texture.image;
|
|
44
|
+
if (!image) {
|
|
45
|
+
return;
|
|
8
46
|
}
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
47
|
+
const width = image.width;
|
|
48
|
+
const height = image.height;
|
|
49
|
+
const data = image.data;
|
|
50
|
+
const startY = offsetY;
|
|
51
|
+
for (let row = 0; row < height; row += 1) {
|
|
52
|
+
const srcStart = row * width * 4;
|
|
53
|
+
const dstStart = (startY + row) * atlasWidth * 4;
|
|
54
|
+
atlasData.set(data.subarray(srcStart, srcStart + width * 4), dstStart);
|
|
13
55
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const transforms = new Map();
|
|
18
|
-
let offsetY = 0;
|
|
19
|
-
uniqueTextures.forEach(texture => {
|
|
20
|
-
const image = texture.image;
|
|
21
|
-
if (!image) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const width = image.width;
|
|
25
|
-
const height = image.height;
|
|
26
|
-
const data = image.data;
|
|
27
|
-
const startY = offsetY;
|
|
28
|
-
for (let row = 0; row < height; row += 1) {
|
|
29
|
-
const srcStart = row * width * 4;
|
|
30
|
-
const dstStart = ((startY + row) * atlasWidth) * 4;
|
|
31
|
-
atlasData.set(data.subarray(srcStart, srcStart + width * 4), dstStart);
|
|
32
|
-
}
|
|
33
|
-
transforms.set(texture, {
|
|
34
|
-
offset: [0, startY / atlasHeight],
|
|
35
|
-
scale: [width / atlasWidth, height / atlasHeight],
|
|
36
|
-
});
|
|
37
|
-
offsetY += height;
|
|
56
|
+
transforms.set(texture, {
|
|
57
|
+
offset: [0, startY / atlasHeight],
|
|
58
|
+
scale: [width / atlasWidth, height / atlasHeight]
|
|
38
59
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
offsetY += height;
|
|
61
|
+
});
|
|
62
|
+
const template = uniqueTextures[0];
|
|
63
|
+
const templateTexture = template;
|
|
64
|
+
const atlasTexture = new THREE.DataTexture(atlasData, atlasWidth, atlasHeight);
|
|
65
|
+
atlasTexture.needsUpdate = true;
|
|
66
|
+
atlasTexture.magFilter = templateTexture.magFilter;
|
|
67
|
+
atlasTexture.minFilter = templateTexture.minFilter;
|
|
68
|
+
atlasTexture.wrapS = templateTexture.wrapS;
|
|
69
|
+
atlasTexture.wrapT = templateTexture.wrapT;
|
|
70
|
+
atlasTexture.flipY = false;
|
|
71
|
+
if ("colorSpace" in atlasTexture && "colorSpace" in templateTexture) {
|
|
72
|
+
atlasTexture.colorSpace = templateTexture.colorSpace;
|
|
73
|
+
} else if ("encoding" in atlasTexture && "encoding" in templateTexture) {
|
|
74
|
+
atlasTexture.encoding = templateTexture.encoding;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
texture: atlasTexture,
|
|
78
|
+
transforms,
|
|
79
|
+
width: atlasWidth,
|
|
80
|
+
height: atlasHeight
|
|
81
|
+
};
|
|
60
82
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
const image = emissive.image;
|
|
73
|
-
const refImage = reference.image;
|
|
74
|
-
if (!image || !refImage) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const texWidth = refImage.width;
|
|
78
|
-
const texHeight = refImage.height;
|
|
79
|
-
const data = image.data;
|
|
80
|
-
const offsetX = Math.round(transform.offset[0] * width);
|
|
81
|
-
const offsetY = Math.round(transform.offset[1] * height);
|
|
82
|
-
for (let row = 0; row < texHeight; row += 1) {
|
|
83
|
-
const srcStart = row * texWidth * 4;
|
|
84
|
-
const dstStart = ((offsetY + row) * width + offsetX) * 4;
|
|
85
|
-
atlasData.set(data.subarray(srcStart, srcStart + texWidth * 4), dstStart);
|
|
86
|
-
}
|
|
87
|
-
template = emissive;
|
|
88
|
-
});
|
|
89
|
-
if (!template) {
|
|
90
|
-
return null;
|
|
83
|
+
function buildEmissiveAtlas(THREE, width, height, transforms, pairs) {
|
|
84
|
+
if (pairs.size === 0) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const atlasData = new Uint8Array(width * height * 4);
|
|
88
|
+
let template = null;
|
|
89
|
+
pairs.forEach((emissive, reference) => {
|
|
90
|
+
const transform = transforms.get(reference);
|
|
91
|
+
if (!transform) {
|
|
92
|
+
return;
|
|
91
93
|
}
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
atlasTexture.minFilter = templateTexture.minFilter;
|
|
97
|
-
atlasTexture.wrapS = templateTexture.wrapS;
|
|
98
|
-
atlasTexture.wrapT = templateTexture.wrapT;
|
|
99
|
-
atlasTexture.flipY = false;
|
|
100
|
-
if ('colorSpace' in atlasTexture && 'colorSpace' in templateTexture) {
|
|
101
|
-
atlasTexture.colorSpace = templateTexture.colorSpace;
|
|
94
|
+
const image = emissive.image;
|
|
95
|
+
const refImage = reference.image;
|
|
96
|
+
if (!image || !refImage) {
|
|
97
|
+
return;
|
|
102
98
|
}
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
const texWidth = refImage.width;
|
|
100
|
+
const texHeight = refImage.height;
|
|
101
|
+
const data = image.data;
|
|
102
|
+
const offsetX = Math.round(transform.offset[0] * width);
|
|
103
|
+
const offsetY = Math.round(transform.offset[1] * height);
|
|
104
|
+
for (let row = 0; row < texHeight; row += 1) {
|
|
105
|
+
const srcStart = row * texWidth * 4;
|
|
106
|
+
const dstStart = ((offsetY + row) * width + offsetX) * 4;
|
|
107
|
+
atlasData.set(data.subarray(srcStart, srcStart + texWidth * 4), dstStart);
|
|
105
108
|
}
|
|
106
|
-
|
|
109
|
+
template = emissive;
|
|
110
|
+
});
|
|
111
|
+
if (!template) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const templateTexture = template;
|
|
115
|
+
const atlasTexture = new THREE.DataTexture(atlasData, width, height);
|
|
116
|
+
atlasTexture.needsUpdate = true;
|
|
117
|
+
atlasTexture.magFilter = templateTexture.magFilter;
|
|
118
|
+
atlasTexture.minFilter = templateTexture.minFilter;
|
|
119
|
+
atlasTexture.wrapS = templateTexture.wrapS;
|
|
120
|
+
atlasTexture.wrapT = templateTexture.wrapT;
|
|
121
|
+
atlasTexture.flipY = false;
|
|
122
|
+
if ("colorSpace" in atlasTexture && "colorSpace" in templateTexture) {
|
|
123
|
+
atlasTexture.colorSpace = templateTexture.colorSpace;
|
|
124
|
+
} else if ("encoding" in atlasTexture && "encoding" in templateTexture) {
|
|
125
|
+
atlasTexture.encoding = templateTexture.encoding;
|
|
126
|
+
}
|
|
127
|
+
return atlasTexture;
|
|
107
128
|
}
|
|
129
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
+
0 && (module.exports = {
|
|
131
|
+
buildEmissiveAtlas,
|
|
132
|
+
buildTextureAtlas
|
|
133
|
+
});
|
|
@@ -1,191 +1,216 @@
|
|
|
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 textures_exports = {};
|
|
19
|
+
__export(textures_exports, {
|
|
20
|
+
buildTexturePixels: () => buildTexturePixels,
|
|
21
|
+
createPatternPlaceholderTexture: () => createPatternPlaceholderTexture,
|
|
22
|
+
createTextureMaterial: () => createTextureMaterial,
|
|
23
|
+
ensureTextureInstance: () => ensureTextureInstance,
|
|
24
|
+
toThreeColorRGB: () => toThreeColorRGB
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(textures_exports);
|
|
1
27
|
function toThreeColor(THREE, rgb) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return color;
|
|
28
|
+
const color = new THREE.Color(rgb[0] / 255, rgb[1] / 255, rgb[2] / 255);
|
|
29
|
+
if (typeof color.convertSRGBToLinear === "function") {
|
|
30
|
+
color.convertSRGBToLinear();
|
|
31
|
+
} else if (typeof color.convertGammaToLinear === "function") {
|
|
32
|
+
color.convertGammaToLinear(2.2);
|
|
33
|
+
}
|
|
34
|
+
return color;
|
|
11
35
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!hasEmissive) {
|
|
41
|
-
hasEmissive = emissive.some(component => component !== 0);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
emissiveBuffer[targetIndex] = 0;
|
|
46
|
-
emissiveBuffer[targetIndex + 1] = 0;
|
|
47
|
-
emissiveBuffer[targetIndex + 2] = 0;
|
|
48
|
-
emissiveBuffer[targetIndex + 3] = 0;
|
|
49
|
-
}
|
|
36
|
+
function buildTexturePixels(context, textureDef, pattern, materialsById) {
|
|
37
|
+
const [width, height] = pattern.size;
|
|
38
|
+
const colorBuffer = new Uint8Array(width * height * 4);
|
|
39
|
+
const emissiveBuffer = new Uint8Array(width * height * 4);
|
|
40
|
+
let hasEmissive = false;
|
|
41
|
+
for (let y = 0; y < height; y += 1) {
|
|
42
|
+
for (let x = 0; x < width; x += 1) {
|
|
43
|
+
const sourceIndex = y * width + x;
|
|
44
|
+
const paletteIndex = pattern.data[sourceIndex];
|
|
45
|
+
const materialId = textureDef.materials[paletteIndex];
|
|
46
|
+
const material = materialId ? materialsById.get(materialId) : void 0;
|
|
47
|
+
const color = material?.baseColor ?? [59, 130, 246];
|
|
48
|
+
const opacityValue = material?.opacity !== void 0 ? Number(material.opacity) : 1;
|
|
49
|
+
const clampedOpacity = Number.isFinite(opacityValue) ? Math.max(0, Math.min(1, opacityValue)) : 1;
|
|
50
|
+
const targetY = height - 1 - y;
|
|
51
|
+
const targetIndex = (targetY * width + x) * 4;
|
|
52
|
+
colorBuffer[targetIndex] = color[0];
|
|
53
|
+
colorBuffer[targetIndex + 1] = color[1];
|
|
54
|
+
colorBuffer[targetIndex + 2] = color[2];
|
|
55
|
+
colorBuffer[targetIndex + 3] = Math.round(clampedOpacity * 255);
|
|
56
|
+
const emissive = material?.emissiveColor ?? null;
|
|
57
|
+
if (emissive) {
|
|
58
|
+
emissiveBuffer[targetIndex] = emissive[0];
|
|
59
|
+
emissiveBuffer[targetIndex + 1] = emissive[1];
|
|
60
|
+
emissiveBuffer[targetIndex + 2] = emissive[2];
|
|
61
|
+
emissiveBuffer[targetIndex + 3] = 255;
|
|
62
|
+
if (!hasEmissive) {
|
|
63
|
+
hasEmissive = emissive.some((component) => component !== 0);
|
|
50
64
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
} else {
|
|
66
|
+
emissiveBuffer[targetIndex] = 0;
|
|
67
|
+
emissiveBuffer[targetIndex + 1] = 0;
|
|
68
|
+
emissiveBuffer[targetIndex + 2] = 0;
|
|
69
|
+
emissiveBuffer[targetIndex + 3] = 0;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
color: colorBuffer,
|
|
75
|
+
emissive: hasEmissive ? emissiveBuffer : null
|
|
76
|
+
};
|
|
56
77
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
context.textureCache.set(textureDef.id, bundle);
|
|
105
|
-
return bundle;
|
|
78
|
+
function ensureTextureInstance(context, textureDef) {
|
|
79
|
+
const cached = context.textureCache.get(textureDef.id);
|
|
80
|
+
if (cached) {
|
|
81
|
+
return cached;
|
|
82
|
+
}
|
|
83
|
+
if (!context.entity) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const pattern = context.entity.patterns.find((entry) => entry.id === textureDef.pattern);
|
|
87
|
+
if (!pattern) {
|
|
88
|
+
console.warn("[boxel-three] pattern not found for texture", textureDef.id);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const { color, emissive } = buildTexturePixels(context, textureDef, pattern, context.materialsById);
|
|
92
|
+
const colorTexture = new context.THREE.DataTexture(color, pattern.size[0], pattern.size[1]);
|
|
93
|
+
colorTexture.needsUpdate = true;
|
|
94
|
+
colorTexture.magFilter = context.THREE.NearestFilter;
|
|
95
|
+
colorTexture.minFilter = context.THREE.NearestFilter;
|
|
96
|
+
colorTexture.wrapS = context.THREE.ClampToEdgeWrapping;
|
|
97
|
+
colorTexture.wrapT = context.THREE.ClampToEdgeWrapping;
|
|
98
|
+
colorTexture.flipY = false;
|
|
99
|
+
if ("colorSpace" in colorTexture) {
|
|
100
|
+
colorTexture.colorSpace = context.THREE.SRGBColorSpace ?? colorTexture.colorSpace;
|
|
101
|
+
} else if ("encoding" in colorTexture) {
|
|
102
|
+
colorTexture.encoding = context.THREE.sRGBEncoding ?? colorTexture.encoding;
|
|
103
|
+
}
|
|
104
|
+
let emissiveTexture;
|
|
105
|
+
if (emissive) {
|
|
106
|
+
emissiveTexture = new context.THREE.DataTexture(emissive, pattern.size[0], pattern.size[1]);
|
|
107
|
+
emissiveTexture.needsUpdate = true;
|
|
108
|
+
emissiveTexture.magFilter = context.THREE.NearestFilter;
|
|
109
|
+
emissiveTexture.minFilter = context.THREE.NearestFilter;
|
|
110
|
+
emissiveTexture.wrapS = context.THREE.ClampToEdgeWrapping;
|
|
111
|
+
emissiveTexture.wrapT = context.THREE.ClampToEdgeWrapping;
|
|
112
|
+
emissiveTexture.flipY = false;
|
|
113
|
+
if ("colorSpace" in emissiveTexture) {
|
|
114
|
+
emissiveTexture.colorSpace = context.THREE.SRGBColorSpace ?? emissiveTexture.colorSpace;
|
|
115
|
+
} else if ("encoding" in emissiveTexture) {
|
|
116
|
+
emissiveTexture.encoding = context.THREE.sRGBEncoding ?? emissiveTexture.encoding;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const bundle = {
|
|
120
|
+
color: colorTexture,
|
|
121
|
+
emissive: emissiveTexture
|
|
122
|
+
};
|
|
123
|
+
context.textureCache.set(textureDef.id, bundle);
|
|
124
|
+
return bundle;
|
|
106
125
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return texture;
|
|
126
|
+
function createPatternPlaceholderTexture(context, pattern) {
|
|
127
|
+
const [width, height] = pattern.size;
|
|
128
|
+
const buffer = new Uint8Array(width * height * 4);
|
|
129
|
+
const maxValue = pattern.data.reduce((acc, value) => Math.max(acc, value), 0);
|
|
130
|
+
const normalizer = maxValue > 0 ? maxValue : 1;
|
|
131
|
+
for (let y = 0; y < height; y += 1) {
|
|
132
|
+
for (let x = 0; x < width; x += 1) {
|
|
133
|
+
const sourceIndex = y * width + x;
|
|
134
|
+
const value = pattern.data[sourceIndex];
|
|
135
|
+
const shade = Math.round(value / normalizer * 255);
|
|
136
|
+
const targetY = height - 1 - y;
|
|
137
|
+
const targetIndex = (targetY * width + x) * 4;
|
|
138
|
+
buffer[targetIndex] = shade;
|
|
139
|
+
buffer[targetIndex + 1] = shade;
|
|
140
|
+
buffer[targetIndex + 2] = shade;
|
|
141
|
+
buffer[targetIndex + 3] = 255;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const texture = new context.THREE.DataTexture(buffer, width, height);
|
|
145
|
+
texture.needsUpdate = true;
|
|
146
|
+
texture.magFilter = context.THREE.NearestFilter;
|
|
147
|
+
texture.minFilter = context.THREE.NearestFilter;
|
|
148
|
+
texture.wrapS = context.THREE.ClampToEdgeWrapping;
|
|
149
|
+
texture.wrapT = context.THREE.ClampToEdgeWrapping;
|
|
150
|
+
texture.flipY = false;
|
|
151
|
+
if ("colorSpace" in texture) {
|
|
152
|
+
texture.colorSpace = context.THREE.SRGBColorSpace ?? texture.colorSpace;
|
|
153
|
+
} else if ("encoding" in texture) {
|
|
154
|
+
texture.encoding = context.THREE.sRGBEncoding ?? texture.encoding;
|
|
155
|
+
}
|
|
156
|
+
return texture;
|
|
139
157
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
const textureDef = context.entity.textures.find(entry => entry.id === textureId);
|
|
151
|
-
if (!textureDef) {
|
|
152
|
-
console.warn('[boxel-three] texture not found', textureId);
|
|
153
|
-
return new context.THREE.MeshStandardMaterial({
|
|
154
|
-
color: 0x3b82f6,
|
|
155
|
-
opacity: 0.45,
|
|
156
|
-
transparent: true,
|
|
157
|
-
metalness: 0,
|
|
158
|
-
roughness: 1,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
const bundle = ensureTextureInstance(context, textureDef);
|
|
162
|
-
if (!bundle) {
|
|
163
|
-
return new context.THREE.MeshStandardMaterial({
|
|
164
|
-
color: 0x3b82f6,
|
|
165
|
-
opacity: 0.45,
|
|
166
|
-
transparent: true,
|
|
167
|
-
metalness: 0,
|
|
168
|
-
roughness: 1,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
const material = new context.THREE.MeshStandardMaterial({
|
|
172
|
-
map: bundle.color,
|
|
173
|
-
transparent: true,
|
|
174
|
-
metalness: 0,
|
|
175
|
-
roughness: 1,
|
|
158
|
+
function createTextureMaterial(context, textureId) {
|
|
159
|
+
if (!textureId || !context.entity) {
|
|
160
|
+
return new context.THREE.MeshStandardMaterial({
|
|
161
|
+
color: 3900150,
|
|
162
|
+
opacity: 0.45,
|
|
163
|
+
transparent: true,
|
|
164
|
+
metalness: 0,
|
|
165
|
+
roughness: 1
|
|
176
166
|
});
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
167
|
+
}
|
|
168
|
+
const textureDef = context.entity.textures.find((entry) => entry.id === textureId);
|
|
169
|
+
if (!textureDef) {
|
|
170
|
+
console.warn("[boxel-three] texture not found", textureId);
|
|
171
|
+
return new context.THREE.MeshStandardMaterial({
|
|
172
|
+
color: 3900150,
|
|
173
|
+
opacity: 0.45,
|
|
174
|
+
transparent: true,
|
|
175
|
+
metalness: 0,
|
|
176
|
+
roughness: 1
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const bundle = ensureTextureInstance(context, textureDef);
|
|
180
|
+
if (!bundle) {
|
|
181
|
+
return new context.THREE.MeshStandardMaterial({
|
|
182
|
+
color: 3900150,
|
|
183
|
+
opacity: 0.45,
|
|
184
|
+
transparent: true,
|
|
185
|
+
metalness: 0,
|
|
186
|
+
roughness: 1
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
const material = new context.THREE.MeshStandardMaterial({
|
|
190
|
+
map: bundle.color,
|
|
191
|
+
transparent: true,
|
|
192
|
+
metalness: 0,
|
|
193
|
+
roughness: 1
|
|
194
|
+
});
|
|
195
|
+
if (bundle.emissive) {
|
|
196
|
+
material.emissiveMap = bundle.emissive;
|
|
197
|
+
material.emissive = new context.THREE.Color(1, 1, 1);
|
|
198
|
+
material.emissiveIntensity = 1;
|
|
199
|
+
} else {
|
|
200
|
+
material.emissive.setRGB(0, 0, 0);
|
|
201
|
+
material.emissiveIntensity = 1;
|
|
202
|
+
}
|
|
203
|
+
material.needsUpdate = true;
|
|
204
|
+
return material;
|
|
188
205
|
}
|
|
189
|
-
|
|
190
|
-
|
|
206
|
+
function toThreeColorRGB(context, rgb) {
|
|
207
|
+
return toThreeColor(context.THREE, rgb);
|
|
191
208
|
}
|
|
209
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
210
|
+
0 && (module.exports = {
|
|
211
|
+
buildTexturePixels,
|
|
212
|
+
createPatternPlaceholderTexture,
|
|
213
|
+
createTextureMaterial,
|
|
214
|
+
ensureTextureInstance,
|
|
215
|
+
toThreeColorRGB
|
|
216
|
+
});
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var types_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(types_exports);
|