@liquidcars/atlas 0.1.27 → 0.1.28
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/README.md +3 -2
- package/demo/index.html +2 -2
- package/dist/liquidcars-atlas.js +29 -5
- package/index.html +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -222,12 +222,13 @@ Una vez publicado, los consumidores podrán instalarlo con `npm install @liquidc
|
|
|
222
222
|
Para probar el paquete sin publicarlo, basta con instalar el tarball generado:
|
|
223
223
|
|
|
224
224
|
```bash
|
|
225
|
-
npm install ./liquidcars-atlas-0.1.
|
|
225
|
+
npm install ./liquidcars-atlas-0.1.28.tgz
|
|
226
226
|
```
|
|
227
227
|
|
|
228
228
|
## Estado
|
|
229
229
|
|
|
230
|
-
`0.1.
|
|
230
|
+
`0.1.28` rasteriza explícitamente los SVG sobre un canvas antes de subirlos a
|
|
231
|
+
WebGL y emite diagnósticos cuando falla la carga o la conversión. `0.1.27` añade carga automática de imágenes SVG remotas, SVG mediante data URI
|
|
231
232
|
y SVG inline, manteniendo las mismas opciones de cara y ajuste que las imágenes
|
|
232
233
|
raster. `0.1.26` mantiene el centro como anclaje implícito de toda relación y utiliza
|
|
233
234
|
los puertos de geometrías externas únicamente cuando el modelo los solicita.
|
package/demo/index.html
CHANGED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
liquidcars-atlas { display: block; width: 100%; max-width: 1480px; margin: 0 auto; }
|
|
15
15
|
code { color: #85e5d3; }
|
|
16
16
|
</style>
|
|
17
|
-
<script type="module" src="../dist/liquidcars-atlas.js?v=0.1.
|
|
17
|
+
<script type="module" src="../dist/liquidcars-atlas.js?v=0.1.28"></script>
|
|
18
18
|
</head>
|
|
19
19
|
<body>
|
|
20
20
|
<header>
|
|
21
21
|
<h1>LiquidCars Atlas</h1>
|
|
22
|
-
<p>Prueba de distribución del componente <code><liquidcars-atlas></code> · v0.1.
|
|
22
|
+
<p>Prueba de distribución del componente <code><liquidcars-atlas></code> · v0.1.28</p>
|
|
23
23
|
</header>
|
|
24
24
|
<main>
|
|
25
25
|
<liquidcars-atlas id="atlas" height="720" relation-mode="selected" shell-labels="on"></liquidcars-atlas>
|
package/dist/liquidcars-atlas.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! LiquidCars Atlas 0.1.
|
|
1
|
+
/*! LiquidCars Atlas 0.1.28 | MIT */
|
|
2
2
|
|
|
3
3
|
// src/three.core.js
|
|
4
4
|
/**
|
|
@@ -29615,7 +29615,7 @@ function partGeometry(part) {
|
|
|
29615
29615
|
if (part.shape === "plane") return new PlaneGeometry(1, 1);
|
|
29616
29616
|
return makeGeometry(part.shape || part.geometry || "box", part.radius, part.segments, part.size);
|
|
29617
29617
|
}
|
|
29618
|
-
function createGeometryContent(definition, entity, modelPalette, invalidate) {
|
|
29618
|
+
function createGeometryContent(definition, entity, modelPalette, invalidate, reportWarning) {
|
|
29619
29619
|
const parameters = resolveGeometryParameters(entity, definition);
|
|
29620
29620
|
const localPalette = {
|
|
29621
29621
|
...modelPalette,
|
|
@@ -29651,6 +29651,7 @@ function createGeometryContent(definition, entity, modelPalette, invalidate) {
|
|
|
29651
29651
|
material.map = new Texture(bitmap);
|
|
29652
29652
|
let cancelled = false;
|
|
29653
29653
|
let objectUrl = null;
|
|
29654
|
+
let svgSource = /^\s*<svg(?:\s|>)/i.test(image) || /^data:image\/svg\+xml/i.test(image) || /\.svg(?:[?#]|$)/i.test(image);
|
|
29654
29655
|
const abortController = new AbortController();
|
|
29655
29656
|
const releaseObjectUrl = () => {
|
|
29656
29657
|
if (!objectUrl) return;
|
|
@@ -29663,8 +29664,27 @@ function createGeometryContent(definition, entity, modelPalette, invalidate) {
|
|
|
29663
29664
|
};
|
|
29664
29665
|
const onLoad = () => {
|
|
29665
29666
|
removeListeners();
|
|
29667
|
+
if (cancelled || !material.map) {
|
|
29668
|
+
releaseObjectUrl();
|
|
29669
|
+
return;
|
|
29670
|
+
}
|
|
29671
|
+
if (svgSource) {
|
|
29672
|
+
try {
|
|
29673
|
+
const aspect = (bitmap.naturalWidth || 1) / Math.max(1, bitmap.naturalHeight || 1);
|
|
29674
|
+
const longestSide = 1024;
|
|
29675
|
+
const canvas = document.createElement("canvas");
|
|
29676
|
+
canvas.width = aspect >= 1 ? longestSide : Math.max(1, Math.round(longestSide * aspect));
|
|
29677
|
+
canvas.height = aspect >= 1 ? Math.max(1, Math.round(longestSide / aspect)) : longestSide;
|
|
29678
|
+
const context = canvas.getContext("2d");
|
|
29679
|
+
if (!context) throw new Error("Canvas 2D is unavailable");
|
|
29680
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
29681
|
+
context.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
|
|
29682
|
+
material.map.image = canvas;
|
|
29683
|
+
} catch (error) {
|
|
29684
|
+
reportWarning?.({ code: "SVG_RASTERIZE_FAILED", geometry: definition.id, entityId: entity.id, image, error });
|
|
29685
|
+
}
|
|
29686
|
+
}
|
|
29666
29687
|
releaseObjectUrl();
|
|
29667
|
-
if (cancelled || !material.map) return;
|
|
29668
29688
|
const fit = part.imageFit || part.fit || "stretch";
|
|
29669
29689
|
const imageAspect = bitmap.naturalWidth / Math.max(1, bitmap.naturalHeight);
|
|
29670
29690
|
const baseWidth = Math.abs(Number(part.size?.[0])) || 1;
|
|
@@ -29688,7 +29708,10 @@ function createGeometryContent(definition, entity, modelPalette, invalidate) {
|
|
|
29688
29708
|
const onError = () => {
|
|
29689
29709
|
removeListeners();
|
|
29690
29710
|
releaseObjectUrl();
|
|
29691
|
-
if (!cancelled)
|
|
29711
|
+
if (!cancelled) {
|
|
29712
|
+
reportWarning?.({ code: "IMAGE_LOAD_FAILED", geometry: definition.id, entityId: entity.id, image });
|
|
29713
|
+
invalidate?.();
|
|
29714
|
+
}
|
|
29692
29715
|
};
|
|
29693
29716
|
material.userData.atlasImageCleanup = () => {
|
|
29694
29717
|
cancelled = true;
|
|
@@ -29716,6 +29739,7 @@ function createGeometryContent(definition, entity, modelPalette, invalidate) {
|
|
|
29716
29739
|
let blob = await response.blob();
|
|
29717
29740
|
const contentType = response.headers.get("content-type") || blob.type;
|
|
29718
29741
|
const looksLikeSvg = /image\/svg\+xml/i.test(contentType) || /\.svg(?:[?#]|$)/i.test(image);
|
|
29742
|
+
svgSource = svgSource || looksLikeSvg;
|
|
29719
29743
|
if (looksLikeSvg && blob.type !== "image/svg+xml") blob = new Blob([await blob.text()], { type: "image/svg+xml" });
|
|
29720
29744
|
if (cancelled) return;
|
|
29721
29745
|
objectUrl = URL.createObjectURL(blob);
|
|
@@ -30413,7 +30437,7 @@ var LiquidCarsAtlas = class extends HTMLElement {
|
|
|
30413
30437
|
node.ports = { ...definition?.anchors || {}, ...entity.ports || {} };
|
|
30414
30438
|
if (isCustom) {
|
|
30415
30439
|
try {
|
|
30416
|
-
const content = createGeometryContent(definition, entity, this.modelData.palette, () => this.invalidate());
|
|
30440
|
+
const content = createGeometryContent(definition, entity, this.modelData.palette, () => this.invalidate(), (detail) => this.dispatchEvent(new CustomEvent("lc-warning", { detail })));
|
|
30417
30441
|
content.root.scale.multiply(new Vector3().fromArray(entity.s));
|
|
30418
30442
|
node.appearanceMaterials = [];
|
|
30419
30443
|
content.root.traverse((object) => {
|
package/index.html
CHANGED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
liquidcars-atlas { display: block; width: 100%; max-width: 1480px; margin: 0 auto; }
|
|
15
15
|
code { color: #85e5d3; }
|
|
16
16
|
</style>
|
|
17
|
-
<script type="module" src="./dist/liquidcars-atlas.js?v=0.1.
|
|
17
|
+
<script type="module" src="./dist/liquidcars-atlas.js?v=0.1.28"></script>
|
|
18
18
|
</head>
|
|
19
19
|
<body>
|
|
20
20
|
<header>
|
|
21
21
|
<h1>LiquidCars Atlas</h1>
|
|
22
|
-
<p>Prueba de distribución del componente <code><liquidcars-atlas></code> · v0.1.
|
|
22
|
+
<p>Prueba de distribución del componente <code><liquidcars-atlas></code> · v0.1.28</p>
|
|
23
23
|
</header>
|
|
24
24
|
<main>
|
|
25
25
|
<liquidcars-atlas id="atlas" height="720" relation-mode="selected" shell-labels="on"></liquidcars-atlas>
|