protect zaps from webgl occasionally being unavailable
This commit is contained in:
parent
e939026295
commit
b5828cdf94
@ -57,6 +57,7 @@ export function Ghost ({ onDone }) {
|
|||||||
const texture = textureRef.current
|
const texture = textureRef.current
|
||||||
if (canvas.ghost) return
|
if (canvas.ghost) return
|
||||||
|
|
||||||
|
try {
|
||||||
canvas.ghost = new GhostCanvas(canvas, texture, {
|
canvas.ghost = new GhostCanvas(canvas, texture, {
|
||||||
size: getRandom(0.025, 0.075),
|
size: getRandom(0.025, 0.075),
|
||||||
tail: {
|
tail: {
|
||||||
@ -72,7 +73,10 @@ export function Ghost ({ onDone }) {
|
|||||||
isFlatColor: false,
|
isFlatColor: false,
|
||||||
onDone
|
onDone
|
||||||
})
|
})
|
||||||
}, [])
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
}, [canvasRef, textureRef, onDone])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -137,6 +141,7 @@ const GhostCanvas = (canvas, texture, params) => {
|
|||||||
|
|
||||||
let uniforms
|
let uniforms
|
||||||
const gl = initShader()
|
const gl = initShader()
|
||||||
|
if (!gl) return
|
||||||
|
|
||||||
function generateRandomPath () {
|
function generateRandomPath () {
|
||||||
const startPoint = {
|
const startPoint = {
|
||||||
@ -167,7 +172,7 @@ const GhostCanvas = (canvas, texture, params) => {
|
|||||||
const path = generateRandomPath()
|
const path = generateRandomPath()
|
||||||
let currentPathIndex = 0
|
let currentPathIndex = 0
|
||||||
let pathStartTime = null
|
let pathStartTime = null
|
||||||
const segmentDuration = getRandom(750, 3000) // How long each Bezier segment should take
|
const segmentDuration = getRandom(750, 1500) // How long each Bezier segment should take
|
||||||
|
|
||||||
function evaluateBezier (bezier, t) {
|
function evaluateBezier (bezier, t) {
|
||||||
const [p0, p1, p2, p3] = bezier
|
const [p0, p1, p2, p3] = bezier
|
||||||
|
Loading…
x
Reference in New Issue
Block a user