Skip to content

Commit a687e5d

Browse files
committed
fix(three-dissolve): add 15s hang timeout for __tailwindReady, run oxfmt
If the CDN GLTF fetch hangs in CI (no response = neither onLoad nor onError fires), __tailwindReady would never resolve and the capture engine would wait until the 120s CI timeout killed it. Use Promise.race with a 15s safety net so the engine can proceed with the background effects even if the model never loads. Also formats the file with oxfmt to fix the Format CI gate.
1 parent 9d0037d commit a687e5d

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

registry/blocks/three-dissolve/three-dissolve.html

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@
5858
<script src="https://cdn.jsdelivr.net/npm/three@0.132.2/examples/js/postprocessing/BokehPass.js"></script>
5959
<script>
6060
let resolveReady;
61-
window.__tailwindReady = new Promise((resolve) => {
61+
var loadPromise = new Promise((resolve) => {
6262
resolveReady = resolve;
6363
});
64+
var hangTimer = new Promise((resolve) => setTimeout(resolve, 15000));
65+
window.__tailwindReady = Promise.race([loadPromise, hangTimer]);
6466

6567
(function () {
6668
function parseVars() {
@@ -72,7 +74,9 @@
7274
for (const d of defs) defaults[d.id] = d.default;
7375
var byComp = window.__hfVariablesByComp;
7476
if (byComp && byComp[compId]) return Object.assign(defaults, byComp[compId]);
75-
var el = document.querySelector('[data-composition-id="' + compId + '"][data-variable-values]');
77+
var el = document.querySelector(
78+
'[data-composition-id="' + compId + '"][data-variable-values]',
79+
);
7680
if (el) {
7781
try {
7882
return Object.assign(defaults, JSON.parse(el.getAttribute("data-variable-values")));
@@ -93,7 +97,11 @@
9397

9498
function hexToVec3(hex) {
9599
const n = parseInt(hex.replace("#", ""), 16);
96-
return new THREE.Vector3(((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255);
100+
return new THREE.Vector3(
101+
((n >> 16) & 255) / 255,
102+
((n >> 8) & 255) / 255,
103+
(n & 255) / 255,
104+
);
97105
}
98106

99107
try {
@@ -120,7 +128,9 @@
120128
const DISSOLVE_END = Number(vars.dissolveEnd) || 7.1;
121129
const PARTICLE_COLOR_VEC = hexToVec3(vars.particleColor || "#1a7aff");
122130
const BG_COLOR = vars.bgColor || "#05070d";
123-
const MODEL_URL = vars.modelUrl || "https://static.heygen.ai/hyperframes-oss/registry/blocks/three-dissolve/scene.gltf";
131+
const MODEL_URL =
132+
vars.modelUrl ||
133+
"https://static.heygen.ai/hyperframes-oss/registry/blocks/three-dissolve/scene.gltf";
124134

125135
const container = document.querySelector('[data-composition-id="three-dissolve"]');
126136
const bgGradient = `radial-gradient(circle at 50% 42%, ${BG_COLOR}44 0%, ${BG_COLOR}cc 44%, ${BG_COLOR} 100%)`;
@@ -458,7 +468,8 @@
458468
box.getCenter(bCenter);
459469
modelMesh.position.sub(bCenter);
460470
var maxDim = Math.max(bSize.x, bSize.y, bSize.z);
461-
var visibleHeight = 2 * camera.position.z * Math.tan(THREE.MathUtils.degToRad(camera.fov / 2));
471+
var visibleHeight =
472+
2 * camera.position.z * Math.tan(THREE.MathUtils.degToRad(camera.fov / 2));
462473
var targetSize = visibleHeight * 0.32;
463474
root.scale.setScalar(maxDim > 0 ? targetSize / maxDim : 1);
464475
modelMesh.updateMatrixWorld(true);

0 commit comments

Comments
 (0)