This commit is contained in:
Piotr Goszczyński committed 2025-03-17 19:46:48 +01:00
1 parent c1fc8b4c5f
commit 59ff67e32a
4 files changed
+26 -42

No files matched your search

+2 -9
View File
@@ -79,10 +79,12 @@ const LwCanvas = ({ className }: { className?: string }) => {
// Load the ticket texture and create the actual ticket mesh
// Replace this URL with your actual ticket texture
const ticketScene = '/images/launchweek/14/supabase-ticket.glb'
const ticketStaticTexture = '/images/launchweek/14/supabase-static-ticket.png'
createTicketMesh(ticketScene, {
width: planeGeometrySize[0],
height: planeGeometrySize[1],
ticketTextureSource: ticketStaticTexture,
debug
})
.then((ticketModel) => {
@@ -160,15 +162,6 @@ const LwCanvas = ({ className }: { className?: string }) => {
const animate = (time?: number) => {
const currentTime = time || 0
// if (ticket) {
// // Add very subtle floating animation with reduced amplitude
// // Smoothly interpolate current position toward target (mouse) position
// const lerpFactor = 0.05 // Lower value = smoother/slower follow
//
// ticket.position.y +=
// (targetY - ticket.position.y) * lerpFactor + Math.sin(currentTime * 0.0007) * 0.02
// }
//
// Update CRT shader time uniform for animation effects
if (crtPass) {
crtPass.uniforms.time.value = currentTime
+24 -33
View File
@@ -232,9 +232,9 @@ export const loadGLTFModel = (url: string): Promise<THREE.Group> => {
export const createTicketMesh = async (
source: string,
options: {
ticketTextureSource?: string
width?: number
height?: number
forceTextureMode?: boolean
enhanceEmissive?: boolean
debug?: boolean
materialOptions?: {
@@ -246,18 +246,26 @@ export const createTicketMesh = async (
} = {}
): Promise<THREE.Object3D> => {
try {
// const width = options.width || 4
// const height = options.height || 2
//
// Determine if we should use texture mode
const useTextureMode =
options.forceTextureMode || !(source.endsWith('.glb') || source.endsWith('.gltf'))
const useTextureMode = !(source.endsWith('.glb') || source.endsWith('.gltf'))
if (!useTextureMode) {
// Load the GLTF model
const model = await loadGLTFModel(source)
const ticketTexture = options.ticketTextureSource ? await loadTexture(options.ticketTextureSource) : null
const objectsNames = ['planet', 'name', 'time', 'date'] as const
if(ticketTexture) {
const ticket = model.getObjectByName('ticket')
if (ticket instanceof THREE.Mesh) {
ticket.material = new THREE.MeshBasicMaterial({
map: ticketTexture,
side: THREE.DoubleSide,
transparent: true,
depthWrite: false,
})
}
}
const objectsNames = ['planet', 'name', 'time', 'date', 'spicies', 'number'] as const
const namedObjects = getNamedTextObjects(objectsNames, model)
const textures = {} as {
[key in (typeof objectsNames)[number]]?: ReturnType<typeof createTextureForObject>
@@ -289,6 +297,14 @@ export const createTicketMesh = async (
text = '03/24/2025'
break
case 'spicies':
text = 'Modern human'
break
case 'number':
text = 'A001'
break
default:
objectName satisfies never
}
@@ -384,31 +400,6 @@ export const createTicketMesh = async (
}
}
/**
* Helper function to create a ticket mesh specifically from a texture
* @param textureUrl URL of the texture to use for the ticket
* @param options Configuration options for the ticket
* @returns Promise that resolves with the created mesh
*/
export const createTextureTicketMesh = async (
textureUrl: string,
options: {
width?: number
height?: number
materialOptions?: {
transparent?: boolean
emissiveColor?: THREE.Color | number
emissiveIntensity?: number
color?: THREE.Color | number
}
} = {}
): Promise<THREE.Mesh> => {
return createTicketMesh(textureUrl, {
...options,
forceTextureMode: true,
}) as Promise<THREE.Mesh>
}
/**
* Custom hook for Three.js setup and animation
* @param setupCallback Callback function for setting up the scene
Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB