<!--
DUTTA INNOVATIONS — Animation page (Elementor-ready)
HOW TO USE: Elementor → new page → Page Layout "Elementor Full Width" → add a Section/Container set to
"Full Width", padding 0 → drop in ONE "HTML" widget → paste this whole file → Update.
Your site header (menu + logo) and footer stay as they are; this page starts directly with the banner.
Enquiries: every WhatsApp button + the form open WhatsApp to +91 91238 32514 with the brief pre-typed.
Change number / email / links / portfolio videos in the CONFIG block inside the first .
-->
#dia {
--ink: #1B1340;
--ink-2: #4A4270;
--muted: #6E6890;
--cream: #FFF7EC;
--paper: #FFFFFF;
--lilac: #EEE8FF;
--coral: #FF5A5F;
--sun: #FFC23C;
--mint: #2EC4B6;
--violet: #7B5CFF;
--sky: #4CC9F0;
--pink: #FF8FB1;
--wa: #25D366;
--r-lg: 28px;
--r-md: 20px;
--r-sm: 14px;
--shadow: 0 18px 50px -18px rgba(39, 22, 110, .28);
--shadow-sm: 0 8px 24px -12px rgba(39, 22, 110, .25);
--display: 'Fredoka', 'Baloo 2', system-ui, sans-serif;
--body: 'Plus Jakarta Sans', 'Baloo 2', system-ui, sans-serif;
--wrap: 1200px;
}
#dia, #dia * {
box-sizing: border-box;
margin: 0;
padding: 0
}
#dia {
scroll-behavior: smooth;
-webkit-text-size-adjust: 100%
}
#dia, #dia {
overflow-x: clip
}
#dia {
font-family: var(--body);
color: var(--ink);
background: var(--cream);
line-height: 1.6;
overflow-x: hidden;
-webkit-font-smoothing: antialiased
}
#dia img, #dia svg, #dia canvas {
display: block;
max-width: 100%
}
#dia a {
color: inherit;
text-decoration: none
}
#dia button {
font: inherit;
color: inherit;
background: none;
border: 0;
cursor: pointer
}
#dia .wrap {
width: min(var(--wrap), 100% - 40px);
margin-inline: auto
}
#dia section {
position: relative
}
#dia h1, #dia h2, #dia h3 {
font-family: var(--display);
line-height: 1.08;
letter-spacing: -.01em
}
#dia .sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0 0 0 0)
}
#dia .cursor-dot, #dia .cursor-ring {
position: fixed;
left: 0;
top: 0;
pointer-events: none;
z-index: 9999;
border-radius: 50%;
transform: translate(-50%, -50%);
display: none
}
#dia .cursor-dot {
width: 8px;
height: 8px;
background: var(--coral)
}
#dia .cursor-ring {
width: 38px;
height: 38px;
border: 2px solid var(--ink);
transition: width .25s, height .25s, background .25s, border-color .25s;
display: none;
align-items: center;
justify-content: center;
font: 700 10px var(--body);
color: #fff;
letter-spacing: .06em;
text-transform: uppercase
}
#dia .cursor-ring.big {
width: 74px;
height: 74px;
background: var(--violet);
border-color: var(--violet)
}
#dia.has-cursor.cur-in .cursor-dot, #dia.has-cursor.cur-in .cursor-ring {
display: flex
}
#dia.has-cursor, #dia.has-cursor a, #dia.has-cursor button, #dia.has-cursor label, #dia.has-cursor summary, #dia.has-cursor canvas {
cursor: none
}
#dia.has-cursor input, #dia.has-cursor textarea, #dia.has-cursor select {
cursor: text
}
#dia .spark {
position: fixed;
pointer-events: none;
z-index: 9998;
width: 8px;
height: 8px;
border-radius: 50%;
transform: translate(-50%, -50%);
animation: spark .7s ease-out forwards
}
@keyframes spark {
to {
transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0);
opacity: 0
}
}
#dia .progress {
position: fixed;
top: 0;
left: 0;
height: 3px;
width: 100%;
transform-origin: 0 50%;
transform: scaleX(0);
background: linear-gradient(90deg, var(--coral), var(--sun), var(--mint), var(--violet));
z-index: 1001
}
#dia .nav {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1000;
transition: background .3s, box-shadow .3s, padding .3s;
padding: 16px 0
}
#dia .nav.scrolled {
background: rgba(255, 247, 236, .86);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
box-shadow: 0 6px 30px -18px rgba(27, 19, 64, .4);
padding: 10px 0
}
#dia .nav .wrap {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px
}
#dia .logo {
display: flex;
align-items: center;
gap: 10px;
min-width: 0
}
#dia .logo-mark {
width: 42px;
height: 42px;
flex: none
}
#dia .logo-mark .eye {
animation: blink 4s infinite;
transform-box: fill-box;
transform-origin: center
}
#dia .logo-text {
display: flex;
flex-direction: column;
line-height: 1.05;
min-width: 0
}
#dia .logo-text b {
font-family: var(--display);
font-size: 17px;
font-weight: 700;
letter-spacing: .02em;
white-space: nowrap
}
#dia .logo-text small {
font-size: 11px;
font-weight: 700;
color: var(--violet);
letter-spacing: .18em;
text-transform: uppercase
}
#dia .nav-links {
display: flex;
align-items: center;
gap: 6px
}
#dia .nav-links a {
padding: 8px 14px;
border-radius: 99px;
font-weight: 600;
font-size: 14.5px;
color: var(--ink-2);
transition: background .2s, color .2s
}
#dia .nav-links a:hover {
background: var(--lilac);
color: var(--ink)
}
#dia .nav-cta {
display: flex;
gap: 10px;
align-items: center
}
#dia .menu-btn {
display: none;
width: 44px;
height: 44px;
border-radius: 14px;
background: var(--paper);
box-shadow: var(--shadow-sm);
align-items: center;
justify-content: center
}
#dia .menu-btn span {
display: block;
width: 18px;
height: 2px;
background: var(--ink);
border-radius: 2px;
position: relative;
transition: .3s
}
#dia .menu-btn span::before, #dia .menu-btn span::after {
content: "";
position: absolute;
left: 0;
width: 18px;
height: 2px;
background: var(--ink);
border-radius: 2px;
transition: .3s
}
#dia .menu-btn span::before {
top: -6px
}
#dia .menu-btn span::after {
top: 6px
}
#dia .nav.open .menu-btn span {
background: transparent
}
#dia .nav.open .menu-btn span::before {
top: 0;
transform: rotate(45deg)
}
#dia .nav.open .menu-btn span::after {
top: 0;
transform: rotate(-45deg)
}
#dia .btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 10px;
padding: 14px 24px;
border-radius: 99px;
font-weight: 700;
font-size: 15.5px;
transition: transform .25s cubic-bezier(.3, 1.6, .5, 1), box-shadow .25s, background .25s;
white-space: nowrap;
position: relative
}
#dia .btn:hover {
transform: translateY(-3px)
}
#dia .btn:active {
transform: translateY(0) scale(.97)
}
#dia .btn-primary {
background: var(--ink);
color: #fff;
box-shadow: 0 12px 26px -10px rgba(27, 19, 64, .6)
}
#dia .btn-primary:hover {
background: #2a1f63
}
#dia .btn-wa {
background: var(--wa);
color: #fff;
box-shadow: 0 12px 26px -10px rgba(37, 211, 102, .7)
}
#dia .btn-ghost {
background: var(--paper);
color: var(--ink);
box-shadow: var(--shadow-sm)
}
#dia .btn-sm {
padding: 10px 18px;
font-size: 14px
}
#dia .btn svg {
width: 20px;
height: 20px;
flex: none
}
#dia .btn .arrow {
transition: transform .25s
}
#dia .btn:hover .arrow {
transform: translateX(4px)
}
#dia .hero {
padding: 48px 0 40px;
overflow: hidden;
background:
radial-gradient(900px 500px at 85% 10%, #E8E0FF 0, transparent 60%), radial-gradient(700px 500px at 0% 90%, #FFE4D2 0, transparent 60%), var(--cream)
}
#dia .hero-grid {
display: grid;
grid-template-columns: minmax(0, .95fr) minmax(0, 1.15fr);
gap: 28px;
align-items: center
}
#dia .eyebrow {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 8px 14px;
border-radius: 99px;
background: var(--paper);
box-shadow: var(--shadow-sm);
font-size: 13px;
font-weight: 700;
color: var(--ink-2);
letter-spacing: .02em
}
#dia .eyebrow .dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--mint);
box-shadow: 0 0 0 0 rgba(46, 196, 182, .6);
animation: ping 1.8s infinite
}
@keyframes ping {
0% {
box-shadow:0 0 0 0 rgba(46, 196, 182, .6)
}
80%, 100% {
box-shadow: 0 0 0 10px rgba(46, 196, 182, 0)
}
}
#dia .hero h1 {
font-size: clamp(2.5rem, 5.3vw, 4.7rem);
font-weight: 700;
margin: 20px 0 14px
}
#dia .hl {
position: relative;
display: inline-block;
color: var(--violet);
white-space: nowrap
}
#dia .hl svg {
position: absolute;
left: -2%;
bottom: -.18em;
width: 104%;
height: .42em;
overflow: visible
}
#dia .hl svg path {
stroke: var(--sun);
stroke-width: 9;
fill: none;
stroke-linecap: round;
stroke-dasharray: 420;
stroke-dashoffset: 420;
animation: draw 1.2s .6s cubic-bezier(.6, 0, .2, 1) forwards
}
@keyframes draw {
to {
stroke-dashoffset: 0
}
}
#dia .rotator {
font-family: var(--display);
font-size: clamp(1.25rem, 2.3vw, 1.75rem);
font-weight: 600;
color: var(--ink-2);
min-height: 1.5em;
display: flex;
flex-wrap: wrap;
gap: .35em;
align-items: baseline
}
#dia .rotator .word {
color: var(--coral);
position: relative;
white-space: nowrap
}
#dia .rotator .caret {
display: inline-block;
width: 3px;
height: 1em;
background: currentColor;
margin-left: 3px;
vertical-align: -.12em;
animation: caret .8s steps(1) infinite
}
@keyframes caret {
50% {
opacity: 0
}
}
#dia .hero-lead {
font-size: clamp(1rem, 1.3vw, 1.12rem);
color: var(--ink-2);
margin: 16px 0 28px;
max-width: 540px
}
#dia .hero-actions {
display: flex;
flex-wrap: wrap;
gap: 12px
}
#dia .trust {
display: flex;
flex-wrap: wrap;
gap: 10px 18px;
margin-top: 26px;
font-size: 13.5px;
font-weight: 600;
color: var(--muted)
}
#dia .trust span {
display: flex;
align-items: center;
gap: 7px
}
#dia .trust i {
width: 20px;
height: 20px;
border-radius: 50%;
display: grid;
place-items: center;
font-style: normal;
font-size: 11px;
color: #fff
}
#dia .hero-stage {
position: relative;
height: min(640px, 76vh);
min-height: 440px;
border-radius: 36px;
background:
radial-gradient(circle at 50% 40%, #FFFFFF 0, #F4EFFF 45%, #E6DCFF 100%);
box-shadow: inset 0 0 0 1px rgba(123, 92, 255, .12), var(--shadow);
overflow: hidden;
touch-action: pan-y
}
#dia .hero-stage canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%
}
#dia .stage-hint {
position: absolute;
left: 50%;
bottom: 16px;
transform: translateX(-50%);
background: rgba(27, 19, 64, .88);
color: #fff;
font-size: 12.5px;
font-weight: 600;
padding: 9px 14px;
border-radius: 99px;
white-space: nowrap;
pointer-events: none;
display: flex;
gap: 8px;
align-items: center;
animation: floaty 3s ease-in-out infinite;
max-width: calc(100% - 24px);
overflow: hidden;
text-overflow: ellipsis
}
@keyframes floaty {
50% {
transform: translate(-50%, -5px)
}
}
#dia .stage-tag {
position: absolute;
top: 16px;
padding: 7px 12px;
border-radius: 12px;
background: #fff;
box-shadow: var(--shadow-sm);
font-size: 12px;
font-weight: 700;
display: flex;
align-items: center;
gap: 6px;
pointer-events: none
}
#dia .stage-tag.l {
left: 16px
}
#dia .stage-tag.r {
right: 16px
}
#dia .stage-tag .rec {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--coral);
animation: blinkdot 1s steps(1) infinite
}
@keyframes blinkdot {
50% {
opacity: .2
}
}
#dia .bubble {
position: absolute;
left: 0;
top: 0;
transform: translate(-50%, -100%) scale(.6);
opacity: 0;
pointer-events: none;
background: #fff;
color: var(--ink);
font: 600 14px var(--display);
padding: 9px 14px;
border-radius: 16px;
box-shadow: var(--shadow);
white-space: nowrap;
transition: opacity .2s, transform .3s cubic-bezier(.3, 1.6, .5, 1);
z-index: 3
}
#dia .bubble::after {
content: "";
position: absolute;
left: 50%;
bottom: -7px;
width: 14px;
height: 14px;
background: #fff;
transform: translateX(-50%) rotate(45deg);
border-radius: 3px
}
#dia .bubble.show {
opacity: 1;
transform: translate(-50%, -100%) scale(1)
}
#dia .stage-fallback {
position: absolute;
inset: 0;
display: none;
place-items: center;
text-align: center;
padding: 30px;
font-family: var(--display);
font-size: 22px;
color: var(--violet)
}
#dia .no-webgl .stage-fallback {
display: grid
}
#dia .marquee {
padding: 26px 0;
background: var(--ink);
color: #fff;
overflow: hidden;
transform: rotate(-1.2deg);
margin: 30px -10px 0;
box-shadow: 0 20px 40px -20px rgba(27, 19, 64, .6)
}
#dia .marquee + .marquee {
background: var(--sun);
color: var(--ink);
transform: rotate(1deg);
margin-top: -16px;
padding: 16px 0
}
#dia .mq-track {
display: flex;
width: max-content;
animation: mq 38s linear infinite
}
#dia .marquee.rev .mq-track {
animation-direction: reverse;
animation-duration: 44s
}
#dia .mq-track span {
font-family: var(--display);
font-size: clamp(1.3rem, 2.6vw, 2rem);
font-weight: 600;
padding: 0 22px;
white-space: nowrap;
display: flex;
align-items: center;
gap: 44px
}
#dia .mq-track span::after {
content: "\2726 ";
color: var(--sun);
font-size: .8em
}
#dia .marquee.rev .mq-track span::after {
color: var(--coral)
}
@keyframes mq {
to {
transform: translateX(-50%)
}
}
#dia .sec {
padding: 110px 0
}
#dia .sec-head {
text-align: center;
max-width: 760px;
margin: 0 auto 56px
}
#dia .sec-head h2 {
font-size: clamp(2rem, 4.4vw, 3.5rem);
margin: 16px 0 14px
}
#dia .sec-head p {
color: var(--ink-2);
font-size: 1.07rem
}
#dia .mark {
position: relative;
white-space: nowrap;
z-index: 0
}
#dia .mark::before {
content: "";
position: absolute;
left: -.12em;
right: -.12em;
bottom: .06em;
height: .38em;
background: var(--sun);
border-radius: 6px;
z-index: -1;
transform: scaleX(0);
transform-origin: 0 50%;
transition: transform .9s .3s cubic-bezier(.6, 0, .2, 1)
}
#dia .in .mark::before, #dia .mark.in::before {
transform: scaleX(1)
}
#dia.js .reveal {
opacity: 0;
transform: translateY(40px);
transition: opacity .9s cubic-bezier(.2, .7, .2, 1), transform .9s cubic-bezier(.2, .7, .2, 1)
}
#dia.js .reveal.in {
opacity: 1;
transform: none
}
#dia .services {
background: linear-gradient(180deg, var(--cream), #FFF2E3)
}
#dia .grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
gap: 26px
}
#dia .card {
background: var(--paper);
border-radius: var(--r-lg);
padding: 14px 14px 22px;
box-shadow: var(--shadow);
transition: transform .35s cubic-bezier(.2, .7, .2, 1), box-shadow .35s;
transform-style: preserve-3d;
will-change: transform;
display: flex;
flex-direction: column
}
#dia .card:hover {
box-shadow: 0 30px 60px -22px rgba(39, 22, 110, .38)
}
#dia .demo {
position: relative;
height: 220px;
border-radius: 20px;
overflow: hidden;
isolation: isolate;
flex: none
}
#dia .card-body {
padding: 20px 10px 0;
display: flex;
flex-direction: column;
flex: 1
}
#dia .card-num {
font: 700 12px var(--body);
letter-spacing: .16em;
color: var(--muted)
}
#dia .card h3 {
font-size: 1.6rem;
margin: 6px 0 8px
}
#dia .card p {
color: var(--ink-2);
font-size: .97rem
}
#dia .tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin: 14px 0 18px
}
#dia .tags span {
font-size: 12px;
font-weight: 700;
padding: 5px 10px;
border-radius: 99px;
background: var(--lilac);
color: var(--violet)
}
#dia .card-actions {
display: flex;
gap: 10px;
margin-top: auto;
flex-wrap: wrap
}
#dia .card-actions .btn {
flex: 1;
min-width: 0
}
#dia .demo-label {
position: absolute;
z-index: 5;
font: 700 11px var(--body);
letter-spacing: .08em;
text-transform: uppercase;
padding: 5px 9px;
border-radius: 9px;
background: rgba(255, 255, 255, .88);
color: var(--ink);
pointer-events: none
}
#dia .demo-label.tl {
top: 10px;
left: 10px
}
#dia .demo-label.tr {
top: 10px;
right: 10px
}
#dia .demo-label.bl {
bottom: 10px;
left: 10px
}
#dia .demo-label.dark {
background: rgba(27, 19, 64, .72);
color: #fff
}
#dia .wb {
background: #fff;
background-image: linear-gradient(#eef0f6 1px, transparent 1px), linear-gradient(90deg, #eef0f6 1px, transparent 1px);
background-size: 22px 22px
}
#dia .wb svg {
width: 100%;
height: 100%
}
#dia .wb-stroke {
fill: none;
stroke: #1B1340;
stroke-width: 3;
stroke-linecap: round;
stroke-linejoin: round
}
#dia .wb-fill {
transition: fill .6s, opacity .6s
}
#dia .wb-all {
transition: opacity .5s
}
#dia .wb-text {
font: 700 22px 'Caveat', cursive;
fill: var(--coral);
opacity: 0;
transition: opacity .6s
}
#dia .d2 svg {
width: 100%;
height: 100%
}
#dia .tb {
transform-box: fill-box
}
#dia .d2-clouds {
animation: clouds 14s linear infinite
}
@keyframes clouds {
to {
transform: translateX(-300px)
}
}
#dia .kid-hop {
transform-box: fill-box;
transform-origin: 50% 100%;
animation: hop 1.1s infinite
}
@keyframes hop {
0%, 100% {
transform:translateY(0) scale(1.1, .9)
}
12% {
transform:translateY(-3px) scale(.93, 1.08)
}
50% {
transform:translateY(-30px) scale(.98, 1.03)
}
88% {
transform: translateY(-3px) scale(.95, 1.05)
}
}
#dia .kid-shadow {
transform-box: fill-box;
transform-origin: center;
animation: shad 1.1s infinite
}
@keyframes shad {
0%, 100% {
transform: scale(1.1);
opacity:.35
}
50% {
transform: scale(.6);
opacity: .15
}
}
#dia .kid-wave {
transform-box: fill-box;
transform-origin: 0% 100%;
animation: wave .5s ease-in-out infinite alternate
}
@keyframes wave {
from {
transform:rotate(-18deg)
}
to {
transform: rotate(22deg)
}
}
#dia .blink {
transform-box: fill-box;
transform-origin: center;
animation: blink 3.2s infinite
}
@keyframes blink {
0%, 44%, 50%, 100% {
transform:scaleY(1)
}
47% {
transform: scaleY(.1)
}
}
#dia .ball {
transform-box: fill-box;
transform-origin: 50% 100%;
animation: ball 1s infinite
}
@keyframes ball {
0% {
transform: translateY(0) scale(.95, 1.05);
animation-timing-function:cubic-bezier(.55, 0, 1, .45)
}
46% {
transform:translateY(84px) scale(.92, 1.1)
}
50% {
transform: translateY(86px) scale(1.35, .68);
animation-timing-function:cubic-bezier(0, .55, .45, 1)
}
56% {
transform:translateY(80px) scale(.92, 1.1)
}
100% {
transform: translateY(0) scale(.95, 1.05)
}
}
#dia .ball.g1 {
opacity: .2;
animation-delay: -.07s
}
#dia .ball.g2 {
opacity: .1;
animation-delay: -.14s
}
#dia .ball-shadow {
transform-box: fill-box;
transform-origin: center;
animation: bshad 1s infinite
}
@keyframes bshad {
0%, 100% {
transform: scale(.5);
opacity:.12
}
50% {
transform: scale(1.1);
opacity: .35
}
}
#dia .d3 {
background: radial-gradient(circle at 50% 35%, #ffffff, #E9E3FF 70%)
}
#dia .d3 canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
touch-action: pan-y
}
#dia .modes {
position: absolute;
left: 10px;
bottom: 10px;
z-index: 5;
display: flex;
gap: 4px;
background: rgba(27, 19, 64, .78);
padding: 4px;
border-radius: 11px
}
#dia .modes span {
font: 700 10.5px var(--body);
letter-spacing: .06em;
text-transform: uppercase;
color: rgba(255, 255, 255, .55);
padding: 4px 8px;
border-radius: 8px;
transition: .3s
}
#dia .modes span.on {
background: #fff;
color: var(--ink)
}
#dia .ai {
background: #0D0926
}
#dia .ai canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%
}
#dia .ad {
background: radial-gradient(circle at 30% 60%, #FFB36B, #FF5A5F 70%)
}
#dia .ad-rays {
position: absolute;
inset: -60%;
background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, .16) 0 9deg, transparent 9deg 18deg);
animation: spin 16s linear infinite
}
@keyframes spin {
to {
transform: rotate(360deg)
}
}
#dia .ad-bottle {
position: absolute;
left: 16%;
bottom: 12%;
width: 54px;
height: 122px;
animation: adBottle 6s infinite
}
#dia .ad-bottle .cap {
position: absolute;
left: 50%;
top: 0;
width: 24px;
height: 16px;
transform: translateX(-50%);
background: var(--mint);
border-radius: 5px 5px 2px 2px
}
#dia .ad-bottle .neck {
position: absolute;
left: 50%;
top: 13px;
width: 20px;
height: 18px;
transform: translateX(-50%);
background: #FFE7A3
}
#dia .ad-bottle .bod {
position: absolute;
left: 0;
right: 0;
top: 28px;
bottom: 0;
background: linear-gradient(90deg, #FFD25A, #FFB703 60%, #F59E0B);
border-radius: 20px 20px 14px 14px;
box-shadow: inset 6px 0 0 rgba(255, 255, 255, .35)
}
#dia .ad-bottle .lbl {
position: absolute;
left: 0;
right: 0;
top: 50px;
height: 38px;
background: #fff;
display: grid;
place-items: center;
font: 700 10px var(--display);
color: var(--coral);
letter-spacing: .04em
}
@keyframes adBottle {
0% {
transform:translateY(160%) rotate(-25deg)
}
12% {
transform:translateY(-6%) rotate(8deg)
}
18% {
transform:translateY(0) rotate(-4deg)
}
24%, 86% {
transform:translateY(0) rotate(0)
}
55% {
transform:translateY(-6px) rotate(2deg)
}
92%, 100% {
transform: translateY(160%) rotate(10deg)
}
}
#dia .ad-burst {
position: absolute;
left: 7%;
top: 10%;
width: 66px;
height: 66px;
background: var(--sun);
clip-path: polygon(50% 0, 61% 20%, 82% 12%, 80% 34%, 100% 42%, 84% 58%, 94% 80%, 71% 80%, 62% 100%, 50% 84%, 38% 100%, 29% 80%, 6% 80%, 16% 58%, 0 42%, 20% 34%, 18% 12%, 39% 20%);
display: grid;
place-items: center;
font: 700 13px var(--display);
color: var(--ink);
animation: burst 6s infinite
}
@keyframes burst {
0%, 16% {
transform:scale(0) rotate(-90deg)
}
24% {
transform:scale(1.25) rotate(10deg)
}
30%, 84% {
transform:scale(1) rotate(-6deg)
}
57% {
transform:scale(1.08) rotate(6deg)
}
92%, 100% {
transform: scale(0) rotate(90deg)
}
}
#dia .ad-copy {
position: absolute;
right: 7%;
top: 20%;
text-align: right;
color: #fff;
max-width: 56%
}
#dia .ad-copy b {
display: block;
font: 700 clamp(20px, 2.2vw, 26px) /1.05 var(--display);
animation: adText 6s infinite;
text-shadow: 0 3px 0 rgba(0, 0, 0, .12)
}
#dia .ad-copy span {
display: block;
font-weight: 700;
font-size: 13px;
opacity: .92;
margin-top: 4px;
animation: adText 6s .15s infinite
}
@keyframes adText {
0%, 22% {
transform: translateX(120%);
opacity:0
}
32%, 84% {
transform: none;
opacity:1
}
92%, 100% {
transform: translateX(120%);
opacity: 0
}
}
#dia .ad-btn {
position: absolute;
right: 7%;
bottom: 24%;
background: #fff;
color: var(--coral);
font-weight: 800;
font-size: 12.5px;
padding: 8px 14px;
border-radius: 99px;
animation: adBtn 6s infinite;
box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .35)
}
@keyframes adBtn {
0%, 36% {
transform:scale(0)
}
42% {
transform:scale(1.2)
}
46%, 84% {
transform:scale(1)
}
60% {
transform:scale(1.08)
}
64% {
transform:scale(1)
}
92%, 100% {
transform: scale(0)
}
}
#dia .ad-bar {
position: absolute;
left: 7%;
right: 7%;
bottom: 9%;
height: 4px;
border-radius: 4px;
background: rgba(255, 255, 255, .35);
overflow: hidden
}
#dia .ad-bar i {
display: block;
height: 100%;
width: 100%;
background: #fff;
transform-origin: 0 50%;
animation: adBar 6s linear infinite
}
@keyframes adBar {
from {
transform:scaleX(0)
}
to {
transform: scaleX(1)
}
}
#dia .vo {
background: linear-gradient(135deg, #FFF1E2, #FFE0EC);
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 12px 14px
}
#dia .vo-langs {
display: flex;
gap: 6px;
flex-wrap: wrap
}
#dia .vo-langs span {
font-size: 11px;
font-weight: 700;
padding: 4px 9px;
border-radius: 99px;
background: #fff;
color: var(--ink-2);
transition: .3s
}
#dia .vo-langs span.on {
background: var(--ink);
color: #fff
}
#dia .vo-mid {
display: flex;
align-items: center;
gap: 14px;
flex: 1;
min-height: 0
}
#dia .mic {
position: relative;
width: 62px;
height: 62px;
flex: none;
border-radius: 50%;
background: var(--coral);
display: grid;
place-items: center
}
#dia .mic::before, #dia .mic::after {
content: "";
position: absolute;
inset: 0;
border-radius: 50%;
border: 2px solid var(--coral);
animation: ring 1.6s infinite
}
#dia .mic::after {
animation-delay: .8s
}
@keyframes ring {
from {
transform: scale(1);
opacity:.7
}
to {
transform: scale(1.7);
opacity: 0
}
}
#dia .mic svg {
width: 28px;
height: 28px
}
#dia .bars {
display: flex;
align-items: center;
gap: 3px;
height: 76px;
flex: 1;
min-width: 0;
overflow: hidden
}
#dia .bars i {
flex: 1;
min-width: 2px;
height: 100%;
border-radius: 3px;
background: linear-gradient(var(--violet), var(--coral));
transform: scaleY(.15);
transform-origin: center
}
#dia .vo-cap {
background: #fff;
border-radius: 12px;
padding: 8px 12px;
font: 600 14px/1.3 var(--display);
color: var(--ink);
min-height: 38px;
box-shadow: var(--shadow-sm);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis
}
#dia .vo-cap .caret {
display: inline-block;
width: 2px;
height: 1em;
background: var(--coral);
margin-left: 2px;
vertical-align: -.12em;
animation: caret .7s steps(1) infinite
}
#dia .rh {
background: linear-gradient(#2E2A78, #6A45B8)
}
#dia .rh .moon {
position: absolute;
right: 20px;
top: 18px;
width: 40px;
height: 40px;
border-radius: 50%;
box-shadow: -10px 6px 0 0 #FFE8A3;
transform: rotate(-20deg)
}
#dia .tw {
position: absolute;
border-radius: 50%;
background: #fff;
animation: tw 2s infinite
}
@keyframes tw {
50% {
opacity: .2;
transform: scale(.5)
}
}
#dia .big-star {
position: absolute;
left: 50%;
top: 44%;
width: 96px;
height: 96px;
margin: -48px 0 0 -48px;
animation: starBob 2.2s ease-in-out infinite
}
@keyframes starBob {
0%, 100% {
transform:translateY(0) rotate(-8deg) scale(1)
}
50% {
transform: translateY(-12px) rotate(8deg) scale(1.08)
}
}
#dia .blocks {
position: absolute;
left: 14px;
bottom: 12px;
display: flex;
gap: 6px
}
#dia .blocks b {
width: 30px;
height: 30px;
border-radius: 8px;
display: grid;
place-items: center;
font: 700 17px var(--display);
color: #fff;
box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .15);
animation: blk 1.6s infinite
}
#dia .blocks b:nth-child(1) {
background: var(--coral)
}
#dia .blocks b:nth-child(2) {
background: var(--sun);
color: var(--ink);
animation-delay: .2s
}
#dia .blocks b:nth-child(3) {
background: var(--mint);
animation-delay: .4s
}
@keyframes blk {
0%, 60%, 100% {
transform:translateY(0)
}
20% {
transform:translateY(-14px) rotate(-8deg)
}
40% {
transform: translateY(0) scale(1.1, .9)
}
}
#dia .note {
position: absolute;
bottom: 20px;
font: 700 22px var(--display);
animation: noteUp 3.2s ease-out forwards;
pointer-events: none
}
@keyframes noteUp {
0% {
transform: translate(0, 0) scale(.4);
opacity:0
}
15% {
opacity: 1;
transform:translate(6px, -30px) scale(1)
}
50% {
transform:translate(-8px, -100px)
}
100% {
transform: translate(10px, -190px) rotate(20deg);
opacity: 0
}
}
#dia .mv {
background: radial-gradient(circle at 50% 50%, #3B2C7A, #120C30 75%)
}
#dia .strip {
position: absolute;
left: 0;
right: 0;
height: 34px;
background: #0A0720;
padding: 8px 0;
z-index: 1
}
#dia .strip.t {
top: 0
}
#dia .strip.b {
bottom: 0
}
#dia .strip::before, #dia .strip::after {
content: "";
position: absolute;
left: 0;
right: 0;
height: 4px;
background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .55) 0 7px, transparent 7px 16px);
animation: holes 1.2s linear infinite
}
#dia .strip::before {
top: 2px
}
#dia .strip::after {
bottom: 2px
}
#dia .strip i {
display: block;
height: 18px;
background: repeating-linear-gradient(90deg, #FF5A5F 0 44px, #0A0720 44px 50px, #FFC23C 50px 94px, #0A0720 94px 100px, #2EC4B6 100px 144px, #0A0720 144px 150px, #7B5CFF 150px 194px, #0A0720 194px 200px);
animation: frames 2.4s linear infinite;
opacity: .9
}
#dia .strip.b i, #dia .strip.b::before, #dia .strip.b::after {
animation-direction: reverse
}
@keyframes frames {
to {
background-position: 200px 0
}
}
@keyframes holes {
to {
background-position: 16px 0
}
}
#dia .spot {
position: absolute;
left: 50%;
top: 0;
width: 260px;
height: 240px;
margin-left: -130px;
background: radial-gradient(ellipse at 50% 0, rgba(255, 240, 190, .35), transparent 70%);
clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%);
animation: sway 4s ease-in-out infinite;
transform-origin: 50% 0
}
@keyframes sway {
50% {
transform:rotate(8deg)
}
0%, 100% {
transform: rotate(-8deg)
}
}
#dia .clap {
position: absolute;
left: 50%;
top: 50%;
width: 150px;
transform: translate(-50%, -44%);
z-index: 2;
filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .4))
}
#dia .clap-arm {
transform-box: view-box;
transform-origin: 12px 36px;
animation: clap 2.4s infinite
}
@keyframes clap {
0%, 60% {
transform:rotate(-26deg)
}
74% {
transform:rotate(0)
}
79% {
transform:rotate(-5deg)
}
84%, 92% {
transform:rotate(0)
}
100% {
transform: rotate(-26deg)
}
}
#dia .aim {
background: #000
}
#dia .aim-scene {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
opacity: 0;
transition: opacity 1.1s ease
}
#dia .aim-scene.on {
opacity: 1;
animation: kb 3.4s ease-out forwards
}
@keyframes kb {
from {
transform:scale(1.16)
}
to {
transform: scale(1.02)
}
}
#dia .letter {
position: absolute;
left: 0;
right: 0;
height: 16px;
background: #000;
z-index: 3
}
#dia .letter.t {
top: 0
}
#dia .letter.b {
bottom: 0
}
#dia .scan {
position: absolute;
left: 0;
right: 0;
height: 40%;
top: -40%;
background: linear-gradient(transparent, rgba(124, 240, 255, .18), transparent);
z-index: 2;
animation: scan 3s linear infinite
}
@keyframes scan {
to {
top: 110%
}
}
#dia .aim-prompt {
position: absolute;
left: 10px;
right: 10px;
bottom: 24px;
z-index: 4;
display: flex;
align-items: center;
gap: 8px;
background: rgba(10, 8, 30, .62);
backdrop-filter: blur(6px);
-webkit-backdrop-filter: blur(6px);
border: 1px solid rgba(255, 255, 255, .18);
color: #fff;
border-radius: 11px;
padding: 7px 10px;
font: 600 11.5px/1.3 ui-monospace, Menlo, monospace
}
#dia .aim-prompt .txt {
flex: 1;
min-width: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis
}
#dia .aim-prompt .pct {
flex: none;
color: #7CF0FF
}
#dia .aim-prompt .spark-i {
flex: none;
color: var(--sun)
}
#dia .more {
margin-top: 46px;
text-align: center
}
#dia .more h4 {
font: 600 1.2rem var(--display);
margin-bottom: 16px;
color: var(--ink-2)
}
#dia .chips {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 10px
}
#dia .chips span {
padding: 10px 16px;
border-radius: 99px;
background: #fff;
box-shadow: var(--shadow-sm);
font-weight: 700;
font-size: 14px;
transition: transform .25s cubic-bezier(.3, 1.6, .5, 1), background .25s, color .25s
}
#dia .chips span:hover {
transform: translateY(-4px) rotate(-2deg);
background: var(--ink);
color: #fff
}
#dia .process {
background: #FFF2E3
}
#dia .steps {
position: relative;
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 22px
}
#dia .track {
position: absolute;
left: 10%;
right: 10%;
top: 44px;
height: 6px;
border-radius: 6px;
background: #F1E2CF
}
#dia .track i {
position: absolute;
inset: 0;
border-radius: 6px;
background: linear-gradient(90deg, var(--coral), var(--sun), var(--mint), var(--violet));
transform-origin: 0 50%;
transform: scaleX(0)
}
#dia .step {
position: relative;
text-align: center;
padding: 0 4px
}
#dia .step .bub {
width: 94px;
height: 94px;
margin: 0 auto 18px;
border-radius: 30px;
display: grid;
place-items: center;
background: #fff;
box-shadow: var(--shadow-sm);
font: 700 30px var(--display);
position: relative;
z-index: 1;
transition: transform .5s cubic-bezier(.3, 1.6, .5, 1), background .4s, color .4s
}
#dia .step.on .bub {
transform: rotate(-6deg) scale(1.06);
color: #fff
}
#dia .step:nth-child(2).on .bub {
background: var(--coral)
}
#dia .step:nth-child(3).on .bub {
background: var(--sun);
color: var(--ink)
}
#dia .step:nth-child(4).on .bub {
background: var(--mint)
}
#dia .step:nth-child(5).on .bub {
background: var(--sky)
}
#dia .step:nth-child(6).on .bub {
background: var(--violet)
}
#dia .step h3 {
font-size: 1.25rem;
margin-bottom: 6px
}
#dia .step p {
font-size: .93rem;
color: var(--ink-2)
}
#dia .studio {
background: var(--ink);
color: #fff;
overflow: hidden
}
#dia .studio::before {
content: "";
position: absolute;
width: 600px;
height: 600px;
border-radius: 50%;
background: radial-gradient(circle, rgba(123, 92, 255, .45), transparent 65%);
top: -200px;
right: -200px
}
#dia .studio::after {
content: "";
position: absolute;
width: 500px;
height: 500px;
border-radius: 50%;
background: radial-gradient(circle, rgba(255, 90, 95, .3), transparent 65%);
bottom: -200px;
left: -160px
}
#dia .studio .wrap {
position: relative;
z-index: 1
}
#dia .studio .sec-head p {
color: rgba(255, 255, 255, .72)
}
#dia .studio .eyebrow {
background: rgba(255, 255, 255, .1);
color: #fff;
box-shadow: none
}
#dia .stats {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 18px;
margin-bottom: 56px
}
#dia .stat {
padding: 26px 20px;
border-radius: var(--r-md);
background: rgba(255, 255, 255, .06);
border: 1px solid rgba(255, 255, 255, .1);
text-align: center
}
#dia .stat b {
display: block;
font: 700 clamp(2.2rem, 4vw, 3.2rem) /1 var(--display);
background: linear-gradient(90deg, var(--sun), var(--coral));
-webkit-background-clip: text;
background-clip: text;
color: transparent
}
#dia .stat span {
display: block;
margin-top: 10px;
font-size: .92rem;
color: rgba(255, 255, 255, .75);
font-weight: 600
}
#dia .why {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 18px
}
#dia .why div {
padding: 26px;
border-radius: var(--r-md);
background: rgba(255, 255, 255, .06);
border: 1px solid rgba(255, 255, 255, .1);
transition: transform .3s, background .3s
}
#dia .why div:hover {
transform: translateY(-6px);
background: rgba(255, 255, 255, .1)
}
#dia .why .ic {
width: 48px;
height: 48px;
border-radius: 15px;
display: grid;
place-items: center;
margin-bottom: 16px;
font-size: 22px
}
#dia .why h3 {
font-size: 1.25rem;
margin-bottom: 8px
}
#dia .why p {
color: rgba(255, 255, 255, .72);
font-size: .95rem
}
#dia .inds {
margin-top: 56px;
text-align: center
}
#dia .inds h4 {
font: 600 1.15rem var(--display);
margin-bottom: 16px;
color: rgba(255, 255, 255, .8)
}
#dia .inds .chips span {
background: rgba(255, 255, 255, .08);
color: #fff;
box-shadow: none;
border: 1px solid rgba(255, 255, 255, .14)
}
#dia .inds .chips span:hover {
background: var(--sun);
color: var(--ink)
}
#dia .contact {
background: radial-gradient(800px 500px at 100% 0, #E8E0FF, transparent 60%), radial-gradient(700px 500px at 0 100%, #FFE1D0, transparent 60%), var(--cream)
}
#dia .contact-grid {
display: grid;
grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr);
gap: 28px;
align-items: start
}
#dia .form {
background: #fff;
border-radius: 32px;
padding: 34px;
box-shadow: var(--shadow)
}
#dia .fstep {
margin-bottom: 26px
}
#dia .fstep > label, #dia .fstep > .lab {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px;
font: 600 1.08rem var(--display);
margin-bottom: 12px
}
#dia .fstep .n {
width: 28px;
height: 28px;
border-radius: 9px;
background: var(--ink);
color: #fff;
display: grid;
place-items: center;
font: 700 13px var(--body);
flex: none
}
#dia .pick {
display: flex;
flex-wrap: wrap;
gap: 8px
}
#dia .pick button {
padding: 9px 14px;
border-radius: 99px;
border: 2px solid #E6E0F5;
font-weight: 700;
font-size: 13.5px;
color: var(--ink-2);
transition: all .2s;
background: #fff
}
#dia .pick button:hover {
border-color: var(--violet);
color: var(--violet)
}
#dia .pick button[aria-pressed="true"] {
background: var(--violet);
border-color: var(--violet);
color: #fff;
transform: scale(1.03)
}
#dia .row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 14px
}
#dia .field {
display: flex;
flex-direction: column;
gap: 6px
}
#dia .field span {
font-size: 13px;
font-weight: 700;
color: var(--ink-2)
}
#dia .field input, #dia .field select, #dia .field textarea {
width: 100%;
font: 500 15px var(--body);
color: var(--ink);
padding: 13px 15px;
border-radius: 14px;
border: 2px solid #E6E0F5;
background: #FCFBFF;
transition: border-color .2s, box-shadow .2s;
outline: none
}
#dia .field textarea {
min-height: 110px;
resize: vertical
}
#dia .field input:focus, #dia .field select:focus, #dia .field textarea:focus {
border-color: var(--violet);
box-shadow: 0 0 0 4px rgba(123, 92, 255, .15)
}
#dia .field.err input {
border-color: var(--coral)
}
#dia .form-actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-top: 22px
}
#dia .form-note {
margin-top: 14px;
font-size: 13px;
color: var(--muted)
}
#dia .form-note a {
color: var(--violet);
font-weight: 700;
text-decoration: underline;
text-underline-offset: 3px
}
#dia .preview {
position: sticky;
top: 96px;
background: #E7DED3;
border-radius: 32px;
padding: 20px;
box-shadow: var(--shadow);
background-image: radial-gradient(rgba(27, 19, 64, .06) 1px, transparent 1px);
background-size: 14px 14px
}
#dia .chat-head {
display: flex;
align-items: center;
gap: 12px;
background: #fff;
border-radius: 18px;
padding: 12px 14px;
margin-bottom: 16px
}
#dia .chat-head .av {
width: 42px;
height: 42px;
border-radius: 50%;
flex: none
}
#dia .chat-head b {
display: block;
font-size: 15px
}
#dia .chat-head small {
color: var(--wa);
font-weight: 700;
font-size: 12px
}
#dia .msg {
background: #DCF8C6;
border-radius: 16px 4px 16px 16px;
padding: 12px 14px;
font-size: 13.5px;
line-height: 1.55;
white-space: pre-wrap;
word-break: break-word;
box-shadow: 0 2px 0 rgba(0, 0, 0, .06);
margin-left: auto;
max-width: 96%;
min-height: 120px
}
#dia .msg .time {
display: block;
text-align: right;
font-size: 11px;
color: #6a7a6a;
margin-top: 6px
}
#dia .typing {
display: inline-flex;
gap: 4px;
padding: 12px 14px;
background: #fff;
border-radius: 4px 16px 16px 16px;
margin-bottom: 12px
}
#dia .typing i {
width: 7px;
height: 7px;
border-radius: 50%;
background: #9aa;
animation: typ 1.2s infinite
}
#dia .typing i:nth-child(2) {
animation-delay: .15s
}
#dia .typing i:nth-child(3) {
animation-delay: .3s
}
@keyframes typ {
0%, 60%, 100% {
transform: none;
opacity:.5
}
30% {
transform: translateY(-5px);
opacity: 1
}
}
#dia .preview-foot {
margin-top: 14px;
font-size: 12.5px;
color: var(--ink-2);
text-align: center;
font-weight: 600
}
#dia .toast {
position: fixed;
left: 50%;
bottom: 30px;
transform: translate(-50%, calc(100% + 80px));
visibility: hidden;
background: var(--ink);
color: #fff;
padding: 14px 20px;
border-radius: 16px;
font-weight: 600;
font-size: 14.5px;
z-index: 2000;
box-shadow: var(--shadow);
transition: transform .45s cubic-bezier(.3, 1.5, .5, 1);
max-width: calc(100% - 30px);
text-align: center
}
#dia .toast.show {
transform: translate(-50%, 0);
visibility: visible
}
#dia .faq-list {
max-width: 820px;
margin: 0 auto;
display: grid;
gap: 14px
}
#dia .faq-list details {
background: #fff;
border-radius: 20px;
box-shadow: var(--shadow-sm);
overflow: hidden
}
#dia .faq-list summary {
list-style: none;
padding: 20px 24px;
font: 600 1.1rem var(--display);
display: flex;
justify-content: space-between;
gap: 16px;
align-items: center
}
#dia .faq-list summary::-webkit-details-marker {
display: none
}
#dia .faq-list summary::after {
content: "+";
flex: none;
width: 32px;
height: 32px;
border-radius: 10px;
background: var(--lilac);
color: var(--violet);
display: grid;
place-items: center;
font-size: 22px;
transition: transform .3s
}
#dia .faq-list details[open] summary::after {
transform: rotate(45deg);
background: var(--violet);
color: #fff
}
#dia .faq-list details p {
padding: 0 24px 22px;
color: var(--ink-2)
}
#dia .cta {
padding: 0 0 110px
}
#dia .cta-box {
position: relative;
border-radius: 40px;
padding: 64px 40px;
background: linear-gradient(120deg, var(--violet), #9B6BFF 45%, var(--coral));
color: #fff;
text-align: center;
overflow: hidden
}
#dia .cta-box h2 {
font-size: clamp(2rem, 4.6vw, 3.6rem);
margin-bottom: 14px;
position: relative
}
#dia .cta-box p {
opacity: .9;
max-width: 560px;
margin: 0 auto 28px;
position: relative
}
#dia .cta-box .hero-actions {
justify-content: center;
position: relative
}
#dia .cta-box .blob {
position: absolute;
border-radius: 50%;
background: rgba(255, 255, 255, .14);
animation: blobf 8s ease-in-out infinite
}
@keyframes blobf {
50% {
transform: translate(20px, -24px) scale(1.1)
}
}
#dia footer {
background: var(--ink);
color: rgba(255, 255, 255, .75);
padding: 64px 0 32px
}
#dia .foot {
display: grid;
grid-template-columns: 1.4fr 1fr 1fr 1fr;
gap: 30px
}
#dia .foot h5 {
font: 600 1.05rem var(--display);
color: #fff;
margin-bottom: 14px
}
#dia .foot a {
display: block;
padding: 4px 0;
font-size: 14.5px;
transition: color .2s
}
#dia .foot a:hover {
color: var(--sun)
}
#dia .foot p {
font-size: 14.5px
}
#dia .foot .logo-text b {
color: #fff
}
#dia .copy {
margin-top: 46px;
padding-top: 24px;
border-top: 1px solid rgba(255, 255, 255, .12);
display: flex;
justify-content: space-between;
flex-wrap: wrap;
gap: 10px;
font-size: 13px
}
#dia .wa-float {
position: fixed;
right: 22px;
bottom: 22px;
z-index: 900;
width: 62px;
height: 62px;
border-radius: 50%;
background: var(--wa);
display: grid;
place-items: center;
box-shadow: 0 14px 30px -8px rgba(37, 211, 102, .7);
transition: transform .3s cubic-bezier(.3, 1.6, .5, 1)
}
#dia .wa-float:hover {
transform: scale(1.1) rotate(-8deg)
}
#dia .wa-float svg {
width: 32px;
height: 32px
}
#dia .wa-float::before {
content: "";
position: absolute;
inset: 0;
border-radius: 50%;
border: 3px solid var(--wa);
animation: ring 2s infinite
}
#dia .wa-float .tip {
position: absolute;
right: 74px;
top: 50%;
transform: translateY(-50%);
background: #fff;
color: var(--ink);
font-weight: 700;
font-size: 13.5px;
padding: 9px 14px;
border-radius: 12px;
white-space: nowrap;
box-shadow: var(--shadow-sm);
opacity: 0;
transition: opacity .3s;
pointer-events: none
}
#dia .wa-float:hover .tip {
opacity: 1
}
#dia .mbar {
display: none
}
#dia .char-slot {
position: relative;
pointer-events: none
}
#dia .head-chars {
display: flex;
justify-content: center;
gap: 14px;
margin: -40px 0 4px
}
#dia .head-chars .char-slot {
width: 170px;
height: 190px
}
@media (min-width: 1200px) {
#dia .sec > .wrap {
position: relative
}
#dia .head-chars {
margin: 0
}
#dia .head-chars .char-slot {
position: absolute;
top: -30px;
width: 230px;
height: 280px
}
#dia .head-chars .hc-l {
left: -24px
}
#dia .head-chars .hc-r {
right: -24px
}
}
#dia .pv-slot {
height: 170px;
margin: -8px 0 4px
}
#dia .cta-slot {
width: min(460px, 100%);
height: 210px;
margin: -34px auto 0
}
#dia .portfolio {
background: linear-gradient(180deg, #FFF2E3, var(--cream))
}
#dia .pf-tabs {
display: flex;
gap: 8px;
justify-content: center;
flex-wrap: wrap;
padding: 4px
}
#dia .pf-tabs button {
flex: none;
padding: 10px 16px;
border-radius: 99px;
background: #fff;
font-weight: 700;
font-size: 14px;
color: var(--ink-2);
box-shadow: var(--shadow-sm);
transition: background .25s, color .25s, transform .25s cubic-bezier(.3, 1.6, .5, 1);
display: flex;
gap: 7px;
align-items: center
}
#dia .pf-tabs button span {
font-size: 11px;
padding: 2px 7px;
border-radius: 99px;
background: var(--lilac);
color: var(--violet)
}
#dia .pf-tabs button:hover {
transform: translateY(-3px)
}
#dia .pf-tabs button[aria-selected="true"] {
background: var(--ink);
color: #fff
}
#dia .pf-tabs button[aria-selected="true"] span {
background: var(--sun);
color: var(--ink)
}
#dia .pf-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
grid-auto-rows: 240px;
grid-auto-flow: dense;
gap: 18px;
margin-top: 30px
}
#dia .tile {
position: relative;
border-radius: 24px;
overflow: hidden;
cursor: pointer;
box-shadow: var(--shadow);
transition: transform .35s cubic-bezier(.2, .7, .2, 1), box-shadow .35s;
isolation: isolate;
background: #EDE6FF;
outline: none
}
#dia .tile.wide {
grid-column: span 2
}
#dia .tile.tall {
grid-row: span 2
}
#dia .tile:hover, #dia .tile:focus-visible {
transform: translateY(-6px);
box-shadow: 0 30px 60px -22px rgba(39, 22, 110, .45)
}
#dia .tile:focus-visible {
box-shadow: 0 0 0 4px var(--violet)
}
#dia .tile.hide {
display: none
}
#dia .tile.pop {
animation: tilePop .55s cubic-bezier(.3, 1.4, .5, 1) both
}
@keyframes tilePop {
from {
opacity: 0;
transform: scale(.86) translateY(24px)
}
}
#dia .tile .ov {
position: absolute;
left: 0;
right: 0;
bottom: 0;
z-index: 6;
padding: 34px 14px 12px 16px;
background: linear-gradient(transparent, rgba(15, 10, 40, .82));
color: #fff;
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 10px
}
#dia .tile .ov small {
display: block;
font-size: 10.5px;
font-weight: 800;
letter-spacing: .12em;
text-transform: uppercase;
color: var(--sun);
margin-bottom: 2px
}
#dia .tile .ov b {
font: 600 16px/1.2 var(--display)
}
#dia .tile .play {
flex: none;
width: 38px;
height: 38px;
border-radius: 50%;
background: #fff;
color: var(--ink);
display: grid;
place-items: center;
font-size: 13px;
padding-left: 2px;
transition: transform .3s cubic-bezier(.3, 1.6, .5, 1)
}
#dia .tile:hover .play {
transform: scale(1.18) rotate(-10deg);
background: var(--sun)
}
#dia .media {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover
}
#dia .pf-more {
text-align: center;
margin-top: 40px
}
#dia .pf-more p {
font: 600 1.15rem var(--display);
margin-bottom: 14px;
color: var(--ink-2)
}
@media (max-width: 640px) {
#dia .tile.wide {
grid-column: auto
}
#dia .tile.tall {
grid-row: auto
}
#dia .pf-tabs {
flex-wrap: nowrap;
overflow-x: auto;
justify-content: flex-start;
scrollbar-width: none;
margin: 0 -20px;
padding: 4px 20px 10px
}
#dia .pf-tabs::-webkit-scrollbar {
display: none
}
}
#dia .ps {
position: absolute;
inset: 0;
overflow: hidden
}
#dia .ps-3d {
background: radial-gradient(circle at 50% 30%, #fff, var(--bg, #E7DEFF) 75%)
}
#dia .ps-3d .char-slot {
position: absolute;
left: 0;
right: 0;
top: 6px;
bottom: 56px
}
#dia .ps-3d .ps-floor {
position: absolute;
left: 18%;
right: 18%;
bottom: 48px;
height: 30px;
border-radius: 50%;
background: rgba(123, 92, 255, .14)
}
#dia .ps-3d .spk {
position: absolute;
color: #fff;
font-size: 16px;
animation: tw 2s infinite;
text-shadow: 0 0 8px rgba(123, 92, 255, .6)
}
#dia .ps-bounce {
background: linear-gradient(#FFD6E7 0 66%, #FFC2D7 66%)
}
#dia .pb-blob {
position: absolute;
left: 50%;
bottom: 34%;
width: 84px;
height: 78px;
margin-left: -42px;
border-radius: 50% 50% 46% 46%;
background: var(--coral);
transform-origin: 50% 100%;
animation: pbB 1s infinite;
box-shadow: inset -8px -6px 0 rgba(0, 0, 0, .08)
}
#dia .pb-blob .e {
position: absolute;
top: 24px;
width: 15px;
height: 19px;
background: #fff;
border-radius: 50%
}
#dia .pb-blob .e::after {
content: "";
position: absolute;
left: 4px;
top: 5px;
width: 8px;
height: 10px;
border-radius: 50%;
background: var(--ink)
}
#dia .pb-blob .l {
left: 20px
}
#dia .pb-blob .r {
right: 20px
}
#dia .pb-blob .m {
position: absolute;
left: 50%;
top: 48px;
width: 20px;
height: 10px;
margin-left: -10px;
border: 3px solid #5a1a2b;
border-top: 0;
border-radius: 0 0 20px 20px
}
@keyframes pbB {
0%, 100% {
transform:translateY(0) scale(1.18, .82)
}
15% {
transform:translateY(-10px) scale(.9, 1.12)
}
50% {
transform:translateY(-72px) scale(.97, 1.04)
}
85% {
transform: translateY(-10px) scale(.92, 1.1)
}
}
#dia .pb-sh {
position: absolute;
left: 50%;
bottom: 31%;
width: 90px;
height: 14px;
margin-left: -45px;
border-radius: 50%;
background: rgba(27, 19, 64, .18);
animation: pbS 1s infinite
}
@keyframes pbS {
0%, 100% {
transform:scale(1.1)
}
50% {
transform: scale(.55);
opacity: .5
}
}
#dia .pb-d {
position: absolute;
width: 10px;
height: 10px;
border-radius: 50%;
animation: tw 2s infinite
}
#dia .ps-walk {
background: linear-gradient(#9EE1FF, #E9F8FF)
}
#dia .pw-far {
position: absolute;
left: 0;
right: 0;
bottom: 24%;
height: 38%;
background: radial-gradient(circle at 50% 100%, #9BE3B9 0 62%, transparent 63%) 0 0/160px 100% repeat-x;
animation: pwS 9s linear infinite
}
#dia .pw-near {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 27%;
background: repeating-linear-gradient(90deg, #5CCB8E 0 30px, #52BF83 30px 60px);
animation: pwS2 1.1s linear infinite
}
@keyframes pwS {
to {
background-position: -160px 0
}
}
@keyframes pwS2 {
to {
background-position: -60px 0
}
}
#dia .pw-kid {
position: absolute;
left: 50%;
bottom: 22%;
height: 55%;
transform: translateX(-50%)
}
#dia .pw-leg, #dia .pw-arm {
transform-box: fill-box;
transform-origin: 50% 8%
}
#dia .pw-leg.a, #dia .pw-arm.b {
animation: sw .55s ease-in-out infinite alternate
}
#dia .pw-leg.b, #dia .pw-arm.a {
animation: sw .55s ease-in-out infinite alternate-reverse
}
@keyframes sw {
from {
transform:rotate(28deg)
}
to {
transform: rotate(-28deg)
}
}
#dia .pw-bob {
animation: pwb .275s ease-in-out infinite alternate
}
@keyframes pwb {
to {
transform: translateY(-2px)
}
}
#dia .ps-wb {
background: #fff;
background-image: linear-gradient(#eef0f6 1px, transparent 1px), linear-gradient(90deg, #eef0f6 1px, transparent 1px);
background-size: 20px 20px
}
#dia .ps-wb svg {
width: 100%;
height: 78%
}
#dia .ps-wb .d {
fill: none;
stroke: #1B1340;
stroke-width: 3;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 320;
stroke-dashoffset: 320;
animation: dr 6s infinite
}
#dia .ps-wb .d1 {
stroke: #F59E0B
}
#dia .ps-wb .d2 {
stroke: #FFC23C;
animation-delay: .5s
}
#dia .ps-wb .d3 {
animation-delay: 1.2s
}
#dia .ps-wb .d4 {
stroke: #7B5CFF;
animation-delay: 2s
}
@keyframes dr {
0% {
stroke-dashoffset: 320;
opacity:1
}
35%, 86% {
stroke-dashoffset: 0;
opacity:1
}
100% {
stroke-dashoffset: 0;
opacity: 0
}
}
#dia .ps-wb .wbt {
font: 700 15px 'Caveat', cursive;
fill: var(--coral);
text-anchor: middle;
animation: wbt 6s infinite
}
@keyframes wbt {
0%, 40% {
opacity:0
}
52%, 86% {
opacity:1
}
100% {
opacity: 0
}
}
#dia .ps-cube {
background: radial-gradient(circle at 50% 30%, #3B2C7A, #120C30);
perspective: 600px
}
#dia .cube {
position: absolute;
left: 50%;
top: 38%;
width: 78px;
height: 78px;
margin: -39px;
transform-style: preserve-3d;
animation: cube 7s linear infinite
}
#dia .cube i {
position: absolute;
inset: 0;
border-radius: 14px;
border: 3px solid rgba(255, 255, 255, .35)
}
#dia .cube .f1 {
background: linear-gradient(135deg, #FF5A5F, #FFC23C);
transform: translateZ(39px)
}
#dia .cube .f2 {
background: linear-gradient(135deg, #7B5CFF, #4CC9F0);
transform: rotateY(180deg) translateZ(39px)
}
#dia .cube .f3 {
background: linear-gradient(135deg, #2EC4B6, #A8FFCF);
transform: rotateY(90deg) translateZ(39px)
}
#dia .cube .f4 {
background: linear-gradient(135deg, #FF8FB1, #FF5A5F);
transform: rotateY(-90deg) translateZ(39px)
}
#dia .cube .f5 {
background: linear-gradient(135deg, #FFC23C, #FFE7A3);
transform: rotateX(90deg) translateZ(39px)
}
#dia .cube .f6 {
background: linear-gradient(135deg, #4CC9F0, #7B5CFF);
transform: rotateX(-90deg) translateZ(39px)
}
@keyframes cube {
to {
transform: rotateX(360deg) rotateY(720deg)
}
}
#dia .cube-sh {
position: absolute;
left: 50%;
top: 66%;
width: 110px;
height: 16px;
margin-left: -55px;
border-radius: 50%;
background: rgba(0, 0, 0, .35);
filter: blur(4px);
animation: pbS 3.5s ease-in-out infinite
}
#dia .ps-ai {
background: #120B2E
}
#dia .ps-ai .bl {
position: absolute;
width: 62%;
aspect-ratio: 1;
border-radius: 42% 58% 63% 37%/45% 40% 60% 55%;
filter: blur(16px);
mix-blend-mode: screen;
opacity: .9
}
#dia .ps-ai .b1 {
background: #FF5A5F;
left: -5%;
top: -12%;
animation: ab1 7s ease-in-out infinite alternate
}
#dia .ps-ai .b2 {
background: #7B5CFF;
right: -8%;
top: 4%;
animation: ab2 8s ease-in-out infinite alternate
}
#dia .ps-ai .b3 {
background: #2EC4B6;
left: 20%;
top: 28%;
animation: ab3 6s ease-in-out infinite alternate
}
#dia .ps-ai.v2 .b1 {
background: #FFC23C
}
#dia .ps-ai.v2 .b3 {
background: #FF8FB1
}
@keyframes ab1 {
to {
transform: translate(40%, 30%) rotate(120deg) scale(1.2)
}
}
@keyframes ab2 {
to {
transform: translate(-40%, 25%) rotate(-140deg)
}
}
@keyframes ab3 {
to {
transform: translate(10%, -35%) rotate(200deg) scale(.8)
}
}
#dia .ps-ai .ai-t {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 24%;
display: grid;
place-items: center;
font: 700 44px var(--display);
color: #fff;
letter-spacing: .08em;
text-shadow: 0 0 24px rgba(255, 255, 255, .6);
animation: aiT 3s ease-in-out infinite
}
@keyframes aiT {
50% {
letter-spacing: .2em;
opacity: .75
}
}
#dia .ps.ad .ad-bottle {
bottom: 30%;
scale: .85;
transform-origin: 50% 100%
}
#dia .ps.ad .ad-copy {
top: 12%
}
#dia .ps.ad .ad-btn {
bottom: 34%
}
#dia .ps.ad .ad-bar {
display: none
}
#dia .ps.rh .blocks {
top: 14px;
bottom: auto
}
#dia .note2 {
position: absolute;
bottom: 30%;
font: 700 20px var(--display);
animation: noteLoop 3s infinite;
opacity: 0
}
@keyframes noteLoop {
0% {
transform: translate(0, 0) scale(.4);
opacity:0
}
15% {
opacity: 1;
transform:translate(6px, -20px) scale(1)
}
100% {
transform: translate(10px, -130px) rotate(20deg);
opacity: 0
}
}
#dia .ps-cin {
background: linear-gradient(#FFB199, #FF6A88 50%, #6A3093)
}
#dia .cin-sun {
position: absolute;
left: 58%;
top: 28%;
width: 46px;
height: 46px;
border-radius: 50%;
background: #FFE7A3;
box-shadow: 0 0 40px #FFE7A3
}
#dia .cin-m {
position: absolute;
left: 0;
width: 200%;
animation: slide 14s linear infinite
}
#dia .cin-m.far {
bottom: 28%;
height: 38%
}
#dia .cin-m.near {
bottom: 0;
height: 42%;
animation-duration: 6s
}
@keyframes slide {
to {
transform: translateX(-50%)
}
}
#dia .cin-bot {
position: absolute;
left: 36%;
bottom: 27%;
width: 40px;
animation: cbob .4s ease-in-out infinite alternate
}
@keyframes cbob {
to {
transform: translateY(-4px) rotate(3deg)
}
}
#dia .cin-wheel {
transform-box: fill-box;
transform-origin: center;
animation: spin .8s linear infinite
}
#dia .cin-t {
position: absolute;
left: 0;
right: 0;
top: 20%;
text-align: center;
font: 700 18px var(--display);
letter-spacing: .22em;
color: #fff;
animation: cinT 5s ease-in-out infinite;
text-shadow: 0 2px 12px rgba(0, 0, 0, .3);
z-index: 2
}
@keyframes cinT {
0%, 8% {
opacity: 0;
letter-spacing:.5em
}
30%, 80% {
opacity: 1;
letter-spacing:.22em
}
100% {
opacity: 0
}
}
#dia .ps-cin .letter {
display: block
}
#dia .ps-logo {
background: radial-gradient(circle at 50% 40%, #2A1F63, #120C30)
}
#dia .ps-logo i {
position: absolute;
left: 50%;
top: 38%;
width: 34px;
height: 34px;
margin: -17px
}
#dia .ps-logo .s1 {
background: var(--coral);
border-radius: 50%;
animation: lg1 4s cubic-bezier(.3, 1.4, .5, 1) infinite
}
#dia .ps-logo .s2 {
background: var(--sun);
border-radius: 8px;
animation: lg2 4s cubic-bezier(.3, 1.4, .5, 1) infinite
}
#dia .ps-logo .s3 {
background: var(--mint);
clip-path: polygon(50% 0, 100% 100%, 0 100%);
animation: lg3 4s cubic-bezier(.3, 1.4, .5, 1) infinite
}
@keyframes lg1 {
0% {
transform: translate(-170px, -120px) rotate(-180deg) scale(.3);
opacity:0
}
25%, 82% {
transform: translate(-46px, 0) rotate(0) scale(1);
opacity:1
}
100% {
transform: translate(-46px, 0) scale(0);
opacity: 0
}
}
@keyframes lg2 {
0%, 8% {
transform: translate(0, -160px) rotate(180deg) scale(.3);
opacity:0
}
33%, 84% {
transform: translate(0, 0) rotate(45deg) scale(1);
opacity:1
}
100% {
transform: scale(0) rotate(45deg);
opacity: 0
}
}
@keyframes lg3 {
0%, 16% {
transform: translate(170px, -120px) rotate(180deg) scale(.3);
opacity:0
}
41%, 86% {
transform: translate(46px, 0) rotate(0) scale(1);
opacity:1
}
100% {
transform: translate(46px, 0) scale(0);
opacity: 0
}
}
#dia .ps-logo b {
position: absolute;
left: 0;
right: 0;
top: 52%;
text-align: center;
font: 700 26px var(--display);
color: #fff;
letter-spacing: .16em;
animation: lgT 4s infinite
}
@keyframes lgT {
0%, 45% {
opacity: 0;
transform:scale(.6)
}
55%, 86% {
opacity: 1;
transform:scale(1)
}
100% {
opacity: 0
}
}
#dia .ps-type {
background: var(--sun)
}
#dia .ps-type .w {
position: absolute;
left: 50%;
top: 40%;
font: 700 44px var(--display);
white-space: nowrap;
opacity: 0;
animation: wT 3.6s infinite
}
#dia .ps-type .w1 {
color: var(--ink)
}
#dia .ps-type .w2 {
color: var(--coral);
animation-delay: 1.2s
}
#dia .ps-type .w3 {
color: var(--violet);
animation-delay: 2.4s
}
@keyframes wT {
0% {
opacity: 0;
transform:translate(-50%, -50%) scale(.3) rotate(-12deg)
}
6% {
opacity: 1;
transform:translate(-50%, -50%) scale(1.15) rotate(4deg)
}
10%, 28% {
opacity: 1;
transform:translate(-50%, -50%) scale(1) rotate(-2deg)
}
33%, 100% {
opacity: 0;
transform: translate(-50%, -50%) scale(1.6)
}
}
#dia .ps-wave {
background: linear-gradient(135deg, #7B5CFF, #FF5A5F);
display: flex;
align-items: center;
justify-content: center;
gap: 14px;
padding: 0 18px 56px
}
#dia .ps-wave .mic {
background: rgba(255, 255, 255, .22)
}
#dia .ps-wave .mic::before, #dia .ps-wave .mic::after {
border-color: #fff
}
#dia .ps-wave .wv {
display: flex;
align-items: center;
gap: 3px;
height: 70px;
flex: 1;
max-width: 220px
}
#dia .ps-wave .wv i {
flex: 1;
height: 100%;
background: #fff;
border-radius: 3px;
transform: scaleY(.2);
animation: vb .9s ease-in-out infinite alternate
}
@keyframes vb {
to {
transform: scaleY(1)
}
}
#dia .ps-wave .wv-l {
position: absolute;
top: 12px;
left: 12px;
font-size: 11.5px;
font-weight: 700;
color: #fff;
background: rgba(0, 0, 0, .22);
padding: 4px 10px;
border-radius: 99px
}
#dia .ps-phone {
background: linear-gradient(135deg, #B8F3EA, #2EC4B6)
}
#dia .phn {
position: absolute;
left: 50%;
top: 14px;
width: 92px;
height: 156px;
margin-left: -46px;
border-radius: 18px;
background: var(--ink);
padding: 8px 6px;
box-shadow: 0 18px 30px -12px rgba(0, 0, 0, .35);
animation: phnF 3s ease-in-out infinite alternate
}
@keyframes phnF {
to {
transform: translateY(-6px) rotate(3deg)
}
}
#dia .scr {
height: 100%;
border-radius: 12px;
background: #fff;
overflow: hidden;
padding: 6px;
display: flex;
flex-direction: column;
gap: 5px
}
#dia .scr .c {
height: 16px;
border-radius: 5px;
background: #EDE6FF;
flex: none;
animation: cIn 3s infinite both
}
#dia .scr .c2 {
animation-delay: .25s;
background: #FFE4D2
}
#dia .scr .c3 {
animation-delay: .5s
}
@keyframes cIn {
0% {
transform:translateX(110%)
}
15%, 80% {
transform:none
}
100% {
transform: translateX(-110%)
}
}
#dia .scr .chart {
flex: 1;
display: flex;
align-items: flex-end;
gap: 4px;
padding: 4px
}
#dia .scr .chart i {
flex: 1;
background: var(--violet);
border-radius: 3px 3px 0 0;
transform-origin: bottom;
animation: grow 3s infinite
}
@keyframes grow {
0% {
transform:scaleY(0)
}
30%, 85% {
transform:scaleY(1)
}
100% {
transform: scaleY(0)
}
}
#dia .ps-phone .fl {
position: absolute;
font-size: 22px;
animation: starBob 2s ease-in-out infinite
}
#dia .lb {
position: fixed;
inset: 0;
z-index: 3000;
display: grid;
place-items: center;
padding: 20px;
opacity: 0;
pointer-events: none;
transition: opacity .3s
}
#dia .lb.open {
opacity: 1;
pointer-events: auto
}
#dia .lb-back {
position: absolute;
inset: 0;
background: rgba(15, 10, 40, .8);
backdrop-filter: blur(6px);
-webkit-backdrop-filter: blur(6px)
}
#dia .lb-box {
position: relative;
width: min(920px, 100%);
max-height: calc(100vh - 40px);
overflow: auto;
background: #fff;
border-radius: 28px;
box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .6);
transform: scale(.92);
transition: transform .35s cubic-bezier(.3, 1.4, .5, 1)
}
#dia .lb.open .lb-box {
transform: none
}
#dia .lb-media {
position: relative
}
#dia .lb-stage {
position: relative;
aspect-ratio: 16/9;
overflow: hidden;
background: #EDE6FF
}
#dia .lb-scale {
position: absolute;
left: 0;
top: 0;
width: 400px;
height: 225px;
transform-origin: 0 0
}
#dia .lb-scale .ps-3d .char-slot {
bottom: 10px
}
#dia .lb-scale .ps-3d .ps-floor {
bottom: 6px
}
#dia .lb-nav {
position: absolute;
top: 50%;
transform: translateY(-50%);
z-index: 6;
width: 46px;
height: 46px;
border-radius: 50%;
background: rgba(255, 255, 255, .92);
font-size: 28px;
line-height: 1;
box-shadow: var(--shadow-sm)
}
#dia .lb-nav.prev {
left: 12px
}
#dia .lb-nav.next {
right: 12px
}
#dia .lb-x {
position: absolute;
top: 12px;
right: 12px;
z-index: 7;
width: 42px;
height: 42px;
border-radius: 50%;
background: #fff;
font-size: 26px;
line-height: 1;
box-shadow: var(--shadow-sm)
}
#dia .lb-info {
display: flex;
justify-content: space-between;
gap: 16px;
align-items: center;
padding: 20px 24px;
flex-wrap: wrap
}
#dia .lb-info h3 {
font-size: 1.5rem;
margin: 6px 0 4px
}
#dia .lb-info p {
color: var(--ink-2);
font-size: .95rem;
max-width: 460px
}
#dia .lb-cat {
font-size: 11px;
font-weight: 800;
letter-spacing: .12em;
text-transform: uppercase;
color: var(--violet);
background: var(--lilac);
padding: 4px 10px;
border-radius: 99px
}
#dia .lb-act {
display: flex;
gap: 10px;
flex-wrap: wrap
}
#dia .char-slot {
position: relative;
pointer-events: auto;
cursor: pointer;
-webkit-tap-highlight-color: transparent
}
#dia .vid .char-slot, #dia .lb-stage .char-slot {
position: absolute;
inset: 0;
pointer-events: none
}
#dia .cbub {
position: fixed;
left: 0;
top: 0;
z-index: 60;
transform: translate(-50%, -100%) scale(.6);
opacity: 0;
background: #fff;
color: var(--ink);
font: 600 14px/1.35 var(--display);
padding: 10px 14px;
border-radius: 16px;
box-shadow: 0 14px 34px -12px rgba(27, 19, 64, .45);
max-width: 250px;
text-align: center;
transition: opacity .2s, transform .35s cubic-bezier(.3, 1.6, .5, 1);
pointer-events: none
}
#dia .cbub::after {
content: "";
position: absolute;
left: 50%;
bottom: -7px;
width: 14px;
height: 14px;
background: #fff;
transform: translateX(-50%) rotate(45deg);
border-radius: 3px
}
#dia .cbub.show {
opacity: 1;
transform: translate(-50%, -100%) scale(1)
}
#dia .cbub-btn {
display: block;
margin-top: 8px;
background: var(--wa);
color: #fff !important;
font: 700 13px var(--body);
padding: 7px 12px;
border-radius: 99px;
pointer-events: auto;
position: relative;
z-index: 1
}
#dia .bubble {
white-space: normal;
max-width: 240px;
text-align: center
}
#dia .emo {
position: fixed;
z-index: 61;
pointer-events: none;
font-size: 24px;
line-height: 1
}
#dia .pf-grid {
grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
grid-auto-rows: auto
}
#dia .tile {
display: flex;
flex-direction: column;
background: #fff;
border-radius: 22px
}
#dia .tile .vid {
position: relative;
aspect-ratio: 16/9;
overflow: hidden;
background: #120C30
}
#dia .film2d {
position: absolute;
inset: 0
}
#dia .film2d svg {
width: 100%;
height: 100%;
display: block
}
#dia .wbsvg {
background: #FDFDFB
}
#dia .wbtx {
font-family: 'Patrick Hand', 'Caveat', cursive
}
#dia .pbar {
height: 4px;
background: #EEE8FF;
flex: none
}
#dia .pbar i {
display: block;
height: 100%;
background: linear-gradient(90deg, var(--coral), var(--violet));
transform-origin: 0 50%;
transform: scaleX(var(--p, 0))
}
#dia .cap {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
padding: 12px 14px 14px
}
#dia .cap-t {
min-width: 0
}
#dia .cap small {
display: block;
font-size: 10.5px;
font-weight: 800;
letter-spacing: .12em;
text-transform: uppercase;
color: var(--violet);
margin-bottom: 3px
}
#dia .cap b {
display: block;
font: 600 15.5px/1.25 var(--display);
color: var(--ink)
}
#dia .cap-r {
display: flex;
align-items: center;
gap: 8px;
flex: none
}
#dia .dur {
font: 700 11.5px var(--body);
background: var(--lilac);
color: var(--violet);
padding: 3px 8px;
border-radius: 7px
}
#dia .cap .play {
width: 36px;
height: 36px;
border-radius: 50%;
background: var(--ink);
color: #fff;
display: grid;
place-items: center;
font-size: 12px;
padding-left: 2px;
transition: transform .3s cubic-bezier(.3, 1.6, .5, 1), background .3s
}
#dia .tile:hover .cap .play {
transform: scale(1.15) rotate(-10deg);
background: var(--coral)
}
#dia .lb-box {
overflow: auto
}
#dia .lb-stage {
aspect-ratio: 16/9;
background: #000
}
#dia .lb-x {
position: fixed;
top: 16px;
right: 16px;
z-index: 3002;
width: 46px;
height: 46px;
border-radius: 50%;
background: #fff;
font-size: 28px;
line-height: 1;
box-shadow: var(--shadow-sm)
}
#dia .lb-info {
display: grid;
grid-template-columns: 1fr auto;
gap: 14px 18px;
align-items: center;
padding: 18px 22px 22px
}
#dia .lb-meta {
grid-column: 1/-1
}
#dia .lb-ctrl {
display: flex;
gap: 8px
}
#dia .lb-btn {
height: 42px;
min-width: 42px;
padding: 0 14px;
border-radius: 99px;
background: var(--lilac);
color: var(--ink);
font-weight: 700;
font-size: 15px
}
#dia .lb-btn:hover {
background: #E0D6FF
}
#dia .lb-btn.snd {
background: var(--ink);
color: #fff
}
@media (max-width: 640px) {
#dia .lb {
padding: 10px
}
#dia .lb-info {
grid-template-columns: 1fr
}
#dia .lb-act .btn {
flex: 1
}
}
@media (max-width: 1100px) {
#dia .steps {
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 14px
}
#dia .step .bub {
width: 80px;
height: 80px;
font-size: 26px
}
#dia .track {
top: 37px
}
}
@media (max-width: 980px) {
#dia .nav-links {
position: absolute;
top: calc(100% + 8px);
left: 16px;
right: 16px;
flex-direction: column;
align-items: stretch;
background: #fff;
border-radius: 22px;
padding: 12px;
box-shadow: var(--shadow);
opacity: 0;
transform: translateY(-10px);
pointer-events: none;
transition: .3s
}
#dia .nav.open .nav-links {
opacity: 1;
transform: none;
pointer-events: auto
}
#dia .nav-links a {
padding: 14px 16px;
font-size: 16px
}
#dia .menu-btn {
display: flex
}
#dia .nav-cta .btn-primary {
display: none
}
#dia .hero {
padding-top: 36px
}
#dia .hero-grid {
grid-template-columns: 1fr;
gap: 26px
}
#dia .hero-copy {
text-align: center
}
#dia .hero-copy .rotator, #dia .hero-actions, #dia .trust {
justify-content: center
}
#dia .hero-lead {
margin-inline: auto
}
#dia .hero-stage {
height: min(560px, 62vh);
min-height: 400px
}
#dia .contact-grid {
grid-template-columns: 1fr
}
#dia .preview {
position: relative;
top: 0
}
#dia .stats {
grid-template-columns: repeat(2, 1fr)
}
#dia .why {
grid-template-columns: repeat(2, 1fr)
}
#dia .foot {
grid-template-columns: 1fr 1fr
}
#dia .steps {
grid-template-columns: 1fr;
gap: 26px;
max-width: 520px;
margin: 0 auto
}
#dia .track {
left: 44px;
right: auto;
top: 40px;
bottom: 40px;
width: 6px;
height: auto
}
#dia .track i {
transform-origin: 50% 0;
transform: scaleY(0)
}
#dia .step {
display: grid;
grid-template-columns: 94px 1fr;
gap: 18px;
text-align: left;
align-items: center
}
#dia .step .bub {
margin: 0;
width: 88px;
height: 88px
}
}
@media (max-width: 700px) {
#dia .sec {
padding: 80px 0
}
#dia .sec-head {
margin-bottom: 40px
}
#dia .nav-cta .btn-wa {
display: none
}
#dia .logo-text b {
font-size: 15px
}
#dia .why {
grid-template-columns: 1fr
}
#dia .row {
grid-template-columns: 1fr
}
#dia .form {
padding: 22px 18px;
border-radius: 26px
}
#dia .wa-float {
display: none
}
#dia .mbar {
display: flex;
position: fixed;
left: 10px;
right: 10px;
bottom: calc(10px + env(safe-area-inset-bottom));
z-index: 900;
gap: 8px;
padding: 8px;
border-radius: 22px;
background: rgba(255, 255, 255, .92);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
box-shadow: 0 12px 34px -12px rgba(27, 19, 64, .45);
transform: translateY(160%);
transition: transform .4s cubic-bezier(.3, 1.4, .5, 1)
}
#dia .mbar.show {
transform: none
}
#dia .mbar .btn {
flex: 1;
padding: 13px 10px;
font-size: 14.5px
}
#dia {
padding-bottom: 84px
}
#dia .toast {
bottom: 100px
}
#dia .cta-box {
padding: 48px 22px;
border-radius: 30px
}
#dia .foot {
grid-template-columns: 1fr
}
#dia .demo {
height: 210px
}
#dia .stage-tag {
display: none
}
#dia .head-chars {
margin-top: -30px
}
#dia .head-chars .char-slot {
width: 140px;
height: 160px
}
#dia .hero-stage {
height: min(470px, 60vh);
min-height: 380px;
border-radius: 28px
}
#dia .eyebrow {
font-size: 12px
}
}
@media (max-width: 380px) {
#dia .stats {
grid-template-columns: 1fr
}
#dia .hero h1 {
font-size: 2.25rem
}
#dia .card-actions .btn {
flex: 1 1 100%
}
}
@media (prefers-reduced-motion: reduce) {
#dia {
scroll-behavior: auto
}
#dia .mq-track {
animation-duration: 120s
}
#dia.js .reveal {
transition-duration: .01s;
transform: none
}
}
#dia {
position: relative;
display: block;
width: 100%;
overflow-x: clip;
-webkit-text-size-adjust: 100%
}
#dia img, #dia svg, #dia canvas {
max-width: none
}
#dia .tile .vid canvas, #dia svg.f2d, #dia svg.wbsvg {
max-width: 100%
}
document.getElementById("dia").classList.add("js");
Animation Studio in Kolkata, Bengaluru & Mumbai
We make characters
come alive.
Your studio for
2D Animation
From 15-second Reels to full-length 3D movies, we write, design, animate and voice stories your audience actually remembers. One passionate team, from script to screen.
✓
8+ years of animation & ads
✓
Script to screen, all in-house
✓
Hindi & English voiceovers
Live 3D, real-time
100% made in-house ✦
Hi!
👀 Move your cursor, they're watching. Tap one!
Our characters are waving at you! ✦
2D Animation
3D Animation
Whiteboard Videos
AI Animation
Commercial Ads
Voiceover
Nursery Rhymes
3D Stories
3D Movies
AI Films
2D Animation
3D Animation
Whiteboard Videos
AI Animation
Commercial Ads
Voiceover
Nursery Rhymes
3D Stories
3D Movies
AI Films
Explainers
Kids Series
Product Films
Reels & Shorts
TV Commercials
Character Design
Storyboards
Music Videos
Explainers
Kids Series
Product Films
Reels & Shorts
TV Commercials
Character Design
Storyboards
Music Videos
✦ What we create
Every kind of animation.
One studio.
Every card below is a live mini-animation. Hover, drag and play with them — it's the same energy we bring to your brand, classroom or channel.
Hand-drawn
Idea → Growth!
01 / WHITEBOARD
Whiteboard Animation
Hand-drawn explainers that make complex ideas simple — ideal for ed-tech, training, product walkthroughs and government campaigns.
Explainers
E-learning
Training
24 FPS · F01
Squash · Stretch · Onion skin
02 / 2D
2D Animation
Expressive character animation, motion graphics and explainers — bouncy, colourful and full of personality.
Character animation
Motion graphics
Cartoons
Drag to spin ↻
Wireframe
Clay
Render
03 / 3D
3D Animation
Modelling, rigging, lighting and final render — 3D characters, products and whole worlds that feel real enough to touch.
3D characters
Product 3D
Walkthroughs
AI · morphing
Move cursor ✦
04 / AI
AI Animation
AI-accelerated pipelines that turn ideas into animated visuals faster — always art-directed and polished by real animators.
AI visuals
Fast turnaround
Social content
AD · 0:15
NEW!
Sip the
summer!
Your brand, animated.
Shop now →
05 / ADS
Commercial Ads
Scroll-stopping ad films for TV, YouTube and Reels — concept, script, animation, music and voice, built to sell.
TV commercials
YouTube ads
Reels ads
हिंदी
English
Kids voice
Ad VO
06 / VOICE
Voiceover
Studio-quality voiceovers in Hindi, English and more — narration, ad VOs, character and kids' voices, dubbing.
Hindi
English
Character voices
07 / KIDS
Rhymes & Kids Content
Nursery rhymes, learning songs and kids' series with lovable characters that children want to watch again and again.
Nursery rhymes
Learning songs
Kids channels
08 / FILMS
3D Stories & 3D Movies
Short 3D stories, episodic series and full-length 3D movies — story, characters, sets, lighting, music and sound, end to end.
3D stories
Web series
Feature films
09 / AI FILMS
AI Movies & AI Films
AI-generated short films, music videos, trailers and cinematic stories — directed, edited and sound-designed by our team.
AI short films
Music videos
Trailers
…and everything in between
Explainer Videos
Motion Graphics
Logo Animation
Character & Mascot Design
Scriptwriting
Storyboarding
Product Animation
Educational Videos
Reels & Shorts
Music & Sound Design
Dubbing & Subtitles
✦ Portfolio
Fresh from our
animation lab.
Short 10-second glimpses of what we make. Pick a category, then tap any film to watch it big, with music and sound effects.
✦ How it works
From a spark of an idea to
screen-ready.
A clear, friendly process. You see and approve every stage before we move to the next.
💡
Brief & Idea
Share your goal, audience and budget. We suggest the right style and format.
✍️
Script & Storyboard
Words first, then frame-by-frame sketches — see your film before it's made.
🎨
Characters & Voice
Custom characters, design boards and voiceover recording.
🎬
Animate & Polish
Animation, music, SFX and colour — reviewed with you at every milestone.
🚀
Deliver Everywhere
Exports for YouTube, Reels, TV, OTT and presentations — every size and ratio.
✦ Why Dutta Innovations
A full animation studio,
right here in India.
Writers, designers, animators, 3D artists and voice artists under one roof, so your project never gets lost between vendors.
0
Years crafting stories
0
Studios: Kolkata, Bengaluru, Mumbai
0
Animation styles
0
Team, script to screen
🎯
Built to convert
Every frame is planned around your goal — sales, sign-ups, learning or views.
🧸
Characters with heart
Cute, memorable characters and mascots your audience falls in love with.
🎙️
Voice in your language
Hindi and English voiceovers, plus other Indian languages on request.
⚡
AI-powered speed
Smart AI tools speed up our drafts, and real animators add the magic on top.
📱
Made for every screen
Vertical Reels, YouTube, TV, OTT, classroom projectors — delivered in every ratio.
🤝
Clear, friendly process
Milestone reviews, one point of contact and quick replies on WhatsApp.
Who we animate for
Brands & FMCG
Ed-tech & Schools
YouTube Kids Channels
Startups & SaaS
Real Estate
Healthcare
Government & NGOs
Creators & Influencers
Film & OTT
✦ Good questions
Frequently
asked
What types of animation do you make?
Whiteboard, 2D, 3D and AI animation, commercial ads, nursery rhymes and kids' content, 3D stories, 3D movies, AI films, explainers, motion graphics, logo animation — plus voiceovers, music and sound.
How long does a project take?
It depends on length and style — a short social ad moves much faster than a 3D series. Share your brief and we'll send a clear timeline together with the quote.
How much does an animation cost?
Pricing depends on duration, style (2D, 3D, AI), number of characters and voiceover needs. Send us your idea on WhatsApp and we'll recommend options that fit your budget.
Do you provide voiceovers in Hindi and other languages?
Yes — Hindi and English voiceovers, including kids' and character voices. Other Indian languages are available on request.
Can I see drafts and ask for changes?
Absolutely. You review the script, storyboard and animation at each milestone, and feedback rounds are planned into the schedule.
Do you work with clients outside Kolkata, Bengaluru and Mumbai?
Yes — we work with clients across India and overseas. Everything can be handled online, from briefing to final delivery.
Your characters are waiting.
Share your idea today. We'll reply with a style suggestion, a clear timeline and a quote.
Chat with us 👋
(function() {
/* ======== CONFIG \u2014 edit these ======== */
var CONFIG = {
whatsapp: '919123832514',
// country code + number, no + or spaces
email: 'info@duttainnovations.com',
contactUrl: 'https://duttainnovations.com/contact/',
mainSite: 'https://www.duttainnovations.com',
formspree: '' // optional: 'https://formspree.io/f/XXXXXXX'
};
window.DI_CONFIG = CONFIG;
var ROOT = document.getElementById('dia') || document.body;
var reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
var fine = matchMedia('(hover:hover) and (pointer:fine)').matches;
var $ = function(s, c) {
return (c || document).querySelector(s)
},
$$ = function(s, c) {
return Array.prototype.slice.call((c || document).querySelectorAll(s))
};
function waLink(t) {
return 'https://wa.me/' + CONFIG.whatsapp + '?text=' + encodeURIComponent(t)
}
/* links */
$$('[data-wa]').forEach(function(a) {
a.href = waLink(a.getAttribute('data-wa'))
});
[['#contactLink', 'href', CONFIG.contactUrl], ['#contactLink2', 'href', CONFIG.contactUrl], ['#mainSite', 'href', CONFIG.mainSite], ['#mailLink', 'href', 'mailto:' + CONFIG.email]].forEach(function(x) {
var e = $(x[0]);
if (e)
e[x[1]] = x[2];
});
/* nav, progress, mobile bar */
var mbar = $('#mbar');
function onScroll() {
var y = scrollY,
h = document.documentElement.scrollHeight - innerHeight;
mbar.classList.toggle('show', y > innerHeight * .5);
processProgress();
}
addEventListener('scroll', onScroll, {
passive: true
});
/* reveal */
var io = new IntersectionObserver(function(es) {
es.forEach(function(e) {
if (e.isIntersecting) {
e.target.classList.add('in');
io.unobserve(e.target)
}
})
}, {
threshold: .14,
rootMargin: '0px 0px -40px 0px'
});
$$('.reveal,.sec-head').forEach(function(el) {
io.observe(el)
});
/* visibility flags for demo loops */
var vis = new WeakMap();
var vio = new IntersectionObserver(function(es) {
es.forEach(function(e) {
vis.set(e.target, e.isIntersecting)
})
}, {
threshold: 0
});
function watch(el) {
if (el) {
vis.set(el, false);
vio.observe(el)
}
return el
}
function isVis(el) {
return !!vis.get(el)
}
/* hero word rotator */
(function() {
var words = ['2D Animation', '3D Animation', 'Whiteboard Videos', 'AI Animation', 'Commercial Ads', 'Kids Rhymes', '3D Stories', '3D Movies', 'AI Films', 'Voiceovers'];
var cols = ['#FF5A5F', '#7B5CFF', '#2EC4B6', '#F59E0B', '#4CC9F0'];
var el = $('#rotWord'),
wi = 0,
ci = words[0].length,
del = false;
function tick() {
var w = words[wi];
if (!del) {
ci++;
el.textContent = w.slice(0, ci);
if (ci >= w.length) {
del = true;
return setTimeout(tick, 1500)
}
}
else {
ci--;
el.textContent = w.slice(0, ci);
if (ci 45) {
last = now;
var s = document.createElement('i');
s.className = 'spark';
s.style.left = mx + 'px';
s.style.top = my + 'px';
s.style.background = colors[(Math.random() * 5) | 0];
s.style.setProperty('--dx', (Math.random() * 40 - 20) + 'px');
s.style.setProperty('--dy', (Math.random() * 40 - 10) + 'px');
ROOT.appendChild(s);
setTimeout(function() {
s.remove()
}, 700)
}
}, {
passive: true
});
(function loop() {
rx += (mx - rx) * .18;
ry += (my - ry) * .18;
ring.style.transform = 'translate(' + rx + 'px,' + ry + 'px) translate(-50%,-50%)';
requestAnimationFrame(loop)
})();
document.addEventListener('pointerover', function(e) {
var t = e.target.closest('a,button,summary,[data-cursor],#heroCanvas,.demo,.tile');
ring.classList.toggle('big', !!t);
ring.textContent = t ? (t.id === 'heroCanvas' ? 'Click' : (t.classList.contains('demo') || t.classList.contains('tile')) ? 'Play' : '') : '';
});
}
/* card tilt */
if (fine && !reduce) {
$$('[data-tilt]').forEach(function(c) {
c.addEventListener('pointermove', function(e) {
var r = c.getBoundingClientRect(),
x = (e.clientX - r.left) / r.width - .5,
y = (e.clientY - r.top) / r.height - .5;
c.style.transform = 'perspective(900px) rotateY(' + (x * 7) + 'deg) rotateX(' + (-y * 7) + 'deg) translateY(-6px)'
});
c.addEventListener('pointerleave', function() {
c.style.transform = ''
});
});
}
/* counters */
var cio = new IntersectionObserver(function(es) {
es.forEach(function(e) {
if (!e.isIntersecting)
return;
cio.unobserve(e.target);
var el = e.target,
to = +el.dataset.count,
suf = el.dataset.suffix || '',
t0 = performance.now();
(function f(t) {
var p = Math.min(1, (t - t0) / 1400);
el.textContent = Math.round(to * (1 - Math.pow(1 - p, 3))) + suf;
if (p < 1)
requestAnimationFrame(f)
})(t0)
})
}, {
threshold: .5
});
$$('[data-count]').forEach(function(el) {
cio.observe(el)
});
/* process progress */
var stepsEl = $('#steps'),
fill = $('#trackFill'),
stepEls = $$('.step');
function processProgress() {
var r = stepsEl.getBoundingClientRect(),
vh = innerHeight;
var p = Math.max(0, Math.min(1, (vh * .75 - r.top) / (r.height + vh * .2)));
var vert = innerWidth = (i / (stepEls.length - 1)) * .92)
});
}
processProgress();
/* ===== 1 whiteboard ===== */
(function() {
var svg = $('#wbSvg'),
demo = watch(svg.parentElement),
all = $('#wbAll'),
hand = $('#wbHand'),
text = $('#wbText'),
bulb = $('#wbBulbFill');
var paths = $$('.wb-stroke', svg),
lens = paths.map(function(p) {
return p.getTotalLength()
});
function reset() {
paths.forEach(function(p, i) {
p.style.strokeDasharray = lens[i];
p.style.strokeDashoffset = lens[i]
});
bulb.style.fill = 'transparent';
text.style.opacity = 0;
all.style.opacity = 1
}
reset();
var idx = 0,
drawn = 0,
state = 'draw',
hold = 0,
lastT = performance.now(),
speed = 230;
function frame(t) {
var dt = Math.min(.05, (t - lastT) / 1000);
lastT = t;
if (isVis(demo)) {
if (state === 'draw') {
var p = paths[idx],
L = lens[idx];
drawn += speed * dt * (reduce ? 3 : 1);
if (drawn >= L) {
drawn = L
}
p.style.strokeDashoffset = L - drawn;
var pt = p.getPointAtLength(drawn);
hand.setAttribute('transform', 'translate(' + pt.x + ',' + pt.y + ')');
if (drawn >= L) {
if (p.dataset.fill)
bulb.style.fill = '#FFE27A';
idx++;
drawn = 0;
if (idx >= paths.length) {
state = 'hold';
hold = 0;
text.style.opacity = 1;
hand.setAttribute('transform', 'translate(250,175)')
}
}
} else if (state === 'hold') {
hold += dt;
if (hold > 2.2) {
state = 'fade';
all.style.opacity = 0;
hold = 0
}
}
else if (state === 'fade') {
hold += dt;
if (hold > .6) {
reset();
idx = 0;
drawn = 0;
state = 'draw'
}
}
}
requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
})();
/* ===== 2 2D frame counter ===== */
(function() {
var l = $('#fpsLabel'),
d = watch(l.parentElement),
f = 1;
setInterval(function() {
if (!isVis(d))
return;
f = f % 24 + 1;
l.textContent = '24 FPS \u00b7 F' + (f < 10 ? '0' : '') + f
}, 1000 / 24)
})();
/* ===== 4 AI particles ===== */
(function() {
var demo = watch($('#aiDemo')),
cv = $('#aiCanvas'),
ctx = cv.getContext('2d'),
label = $('#aiLabel');
var W = 0,
H = 0,
dpr = Math.min(2, devicePixelRatio || 1),
N = innerWidth < 700 ? 260 : 420,
P = [],
shapes = [],
si = 0,
mouse = {
x: -999,
y: -999
};
var names = ['AI', 'heart', 'star', 'play', 'ring'];
function sample(draw) {
var o = document.createElement('canvas');
o.width = W;
o.height = H;
var c = o.getContext('2d');
c.fillStyle = '#fff';
draw(c);
var d = c.getImageData(0, 0, W, H).data,
pts = [],
step = Math.max(2, Math.floor(Math.sqrt(W * H / (N * 3))));
for (var y = 0; y < H; y += step)
for (var x = 0; x 128)
pts.push([x, y]);
for (var i = pts.length - 1; i > 0; i--) {
var j = (Math.random() * (i + 1)) | 0,
t = pts[i];
pts[i] = pts[j];
pts[j] = t
}
var out = [];
for (var k = 0; k < N; k++)
out.push(pts[k % Math.max(1, pts.length)] || [W / 2, H / 2]);
return out;
}
function build() {
W = cv.clientWidth;
H = cv.clientHeight;
if (!W || !H)
return;
cv.width = W * dpr;
cv.height = H * dpr;
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
var cx = W / 2,
cy = H / 2,
s = Math.min(W, H) * .36;
shapes = [
sample(function(c) {
c.font = '800 ' + (s * 1.9) + 'px Fredoka, sans-serif';
c.textAlign = 'center';
c.textBaseline = 'middle';
c.fillText('AI', cx, cy + s * .08)
}),
sample(function(c) {
c.beginPath();
c.moveTo(cx, cy + s * .9);
c.bezierCurveTo(cx - s * 1.6, cy - s * .1, cx - s * .7, cy - s * 1.2, cx, cy - s * .45);
c.bezierCurveTo(cx + s * .7, cy - s * 1.2, cx + s * 1.6, cy - s * .1, cx, cy + s * .9);
c.fill()
}),
sample(function(c) {
c.beginPath();
for (var i = 0; i < 10; i++) {
var a = -Math.PI / 2 + i * Math.PI / 5,
r = i % 2 ? s * .45 : s * 1.05;
c.lineTo(cx + Math.cos(a) * r, cy + Math.sin(a) * r)
}
c.closePath();
c.fill()
}),
sample(function(c) {
c.beginPath();
c.moveTo(cx - s * .6, cy - s * .85);
c.lineTo(cx + s * .95, cy);
c.lineTo(cx - s * .6, cy + s * .85);
c.closePath();
c.fill()
}),
sample(function(c) {
c.beginPath();
c.arc(cx, cy, s, 0, Math.PI * 2);
c.arc(cx, cy, s * .62, 0, Math.PI * 2, true);
c.fill()
})
];
if (!P.length)
for (var i = 0; i < N; i++)
P.push({
x: Math.random() * W,
y: Math.random() * H,
vx: 0,
vy: 0,
h: 200 + Math.random() * 140
});
setTargets();
}
function setTargets() {
var t = shapes[si];
if (!t)
return;
P.forEach(function(p, i) {
p.tx = t[i][0] + (Math.random() - .5) * 2;
p.ty = t[i][1] + (Math.random() - .5) * 2
});
label.textContent = 'AI \u00b7 ' + names[si]
}
new ResizeObserver(build).observe(cv);
setInterval(function() {
if (!isVis(demo) || !shapes.length)
return;
si = (si + 1) % shapes.length;
setTargets();
P.forEach(function(p) {
p.vx += (Math.random() - .5) * 6;
p.vy += (Math.random() - .5) * 6
})
}, 2800);
demo.addEventListener('pointermove', function(e) {
var r = cv.getBoundingClientRect();
mouse.x = e.clientX - r.left;
mouse.y = e.clientY - r.top
});
demo.addEventListener('pointerleave', function() {
mouse.x = mouse.y = -999
});
(function loop(t) {
if (isVis(demo) && W) {
ctx.globalCompositeOperation = 'source-over';
ctx.fillStyle = 'rgba(13,9,38,.32)';
ctx.fillRect(0, 0, W, H);
ctx.globalCompositeOperation = 'lighter';
for (var i = 0; i < P.length; i++) {
var p = P[i];
p.vx += (p.tx - p.x) * .018;
p.vy += (p.ty - p.y) * .018;
var dx = p.x - mouse.x,
dy = p.y - mouse.y,
d2 = dx * dx + dy * dy;
if (d2 < 3600) {
var f = (3600 - d2) / 3600 * 2.4;
var d = Math.sqrt(d2) || 1;
p.vx += dx / d * f;
p.vy += dy / d * f
}
p.vx *= .86;
p.vy *= .86;
p.x += p.vx;
p.y += p.vy;
ctx.fillStyle = 'hsl(' + ((p.h + t * .03) % 360) + ',95%,64%)';
ctx.beginPath();
ctx.arc(p.x, p.y, 1.7, 0, 6.283);
ctx.fill();
}
}
requestAnimationFrame(loop);
})(0);
})();
/* ===== 6 voiceover ===== */
(function() {
var demo = watch($('#voDemo')),
bars = $('#bars'),
txt = $('#voText'),
langs = $$('#voLangs span'),
B = [];
for (var i = 0; i < 34; i++) {
var b = document.createElement('i');
bars.appendChild(b);
B.push(b)
}
var lines = ['\u0928\u092e\u0938\u094d\u0924\u0947! \u0906\u092a\u0915\u0940 \u0915\u0939\u093e\u0928\u0940, \u0939\u092e\u093e\u0930\u0940 \u0906\u0935\u093e\u091c\u093c\u0964', 'Hello! Your story, our voice.', 'Hi friends! Let\u2019s sing and learn! \u2b50', 'New Mango Fizz \u2014 sip the summer!'];
var li = 0,
ci = 0,
speaking = false,
amp = .2,
hover = false;
demo.addEventListener('pointerenter', function() {
hover = true
});
demo.addEventListener('pointerleave', function() {
hover = false
});
function type() {
if (!isVis(demo))
return setTimeout(type, 400);
var L = lines[li];
if (ci < L.length) {
speaking = true;
ci++;
txt.textContent = L.slice(0, ci);
setTimeout(type, 55)
}
else {
speaking = false;
setTimeout(function() {
ci = 0;
li = (li + 1) % lines.length;
langs.forEach(function(s, k) {
s.classList.toggle('on', k === li)
});
txt.textContent = '';
type()
}, 1500)
}
}
type();
(function loop(t) {
if (isVis(demo)) {
t /= 1000;
amp += ((speaking ? 1 : .18) * (hover ? 1.25 : 1) - amp) * .08;
for (var i = 0; i < B.length; i++) {
var v = Math.abs(Math.sin(t * 6.3 + i * .55) * Math.sin(t * 2.7 + i * .23)) * .85 + Math.abs(Math.sin(t * 11 + i)) * .15;
B[i].style.transform = 'scaleY(' + Math.max(.08, Math.min(1, v * amp)) + ')'
}
}
requestAnimationFrame(loop);
})(0);
})();
/* ===== 7 rhymes notes ===== */
(function() {
var d = watch($('#rhDemo')),
ch = ['\u266a', '\u266b', '\u2669', '\u266c'],
co = ['#FFC23C', '#FF8FB1', '#7CF0FF', '#fff', '#A8FFCF'];
setInterval(function() {
if (!isVis(d) || document.hidden)
return;
var n = document.createElement('span');
n.className = 'note';
n.textContent = ch[(Math.random() * 4) | 0];
n.style.left = (20 + Math.random() * 70) + '%';
n.style.color = co[(Math.random() * 5) | 0];
n.style.fontSize = (16 + Math.random() * 14) + 'px';
d.appendChild(n);
n.addEventListener('animationend', function() {
n.remove()
})
}, 420);
})();
/* ===== 8 clapper take counter ===== */
(function() {
var arm = $('.clap-arm'),
no = $('#takeNo'),
k = 1;
arm.addEventListener('animationiteration', function() {
k = k % 9 + 1;
no.textContent = '0' + k
})
})();
/* ===== 9 AI movie ===== */
(function() {
var demo = watch($('#aimDemo')),
sc = $$('.aim-scene', demo),
tx = $('#aimTxt'),
pc = $('#aimPct'),
i = 0;
var prompts = ['a golden sunset over misty hills, birds flying, cinematic', 'neon city at night, glowing windows, 4K film look', 'a cute planet with rings in deep space, Pixar style'];
var t0 = performance.now();
(function loop(t) {
if (isVis(demo)) {
var el = t - t0,
ph = Math.min(1, el / 3200);
var P = prompts[i],
n = Math.min(P.length, Math.floor(el / 28));
tx.textContent = P.slice(0, n);
pc.textContent = (n
P.length * 28 + 1500) {
i = (i + 1) % sc.length;
sc.forEach(function(s, k) {
s.classList.toggle('on', k === i)
});
t0 = t
}
} else
t0 = t;
requestAnimationFrame(loop);
})(performance.now());
})();
/* ===== sound engine (synthesised in the browser \u2014 no audio files needed) ===== */
var SFX = (function() {
var ctx = null,
bus = null,
nb = null,
muted = false,
active = false;
function ac() {
if (!ctx) {
var C = window.AudioContext || window.webkitAudioContext;
if (!C)
return null;
ctx = new C();
newBus();
}
if (ctx.state === 'suspended')
ctx.resume();
return ctx;
}
function newBus() {
if (bus) {
var old = bus;
try {
old.gain.setTargetAtTime(0, ctx.currentTime, 0.04);
} catch (e) {}
setTimeout(function() {
try {
old.disconnect()
} catch (e) {}
}, 400);
}
bus = ctx.createGain();
bus.gain.value = 0.75;
var comp = ctx.createDynamicsCompressor();
bus.connect(comp);
comp.connect(ctx.destination);
}
function noise() {
if (nb)
return nb;
nb = ctx.createBuffer(1, ctx.sampleRate * 2, ctx.sampleRate);
var d = nb.getChannelData(0);
for (var i = 0; i < d.length; i++)
d[i] = Math.random() * 2 - 1;
return nb;
}
function env(g, t, a, dur, v) {
g.gain.setValueAtTime(0.0001, t);
g.gain.exponentialRampToValueAtTime(Math.max(v, 0.0002), t + a);
g.gain.exponentialRampToValueAtTime(0.0001, t + Math.max(dur, a + 0.01));
}
function osc(type, f, t, dur, v, o) {
o = o || {};
var s = ctx.createOscillator(),
g = ctx.createGain();
s.type = type;
s.frequency.setValueAtTime(f, t);
if (o.to)
s.frequency.exponentialRampToValueAtTime(o.to, t + (o.toT || dur));
if (o.det)
s.detune.value = o.det;
env(g, t, o.a || 0.008, dur, v);
var last = g;
if (o.lp) {
var f2 = ctx.createBiquadFilter();
f2.type = 'lowpass';
f2.frequency.value = o.lp;
g.connect(f2);
last = f2;
}
s.connect(g);
last.connect(bus);
s.start(t);
s.stop(t + dur + 0.05);
}
function nz(t, dur, v, type, f, o) {
o = o || {};
var s = ctx.createBufferSource();
s.buffer = noise();
s.loop = true;
var fl = ctx.createBiquadFilter();
fl.type = type;
fl.frequency.setValueAtTime(f, t);
if (o.to)
fl.frequency.exponentialRampToValueAtTime(o.to, t + dur);
fl.Q.value = o.q || 1;
var g = ctx.createGain();
env(g, t, o.a || 0.01, dur, v);
s.connect(fl);
fl.connect(g);
g.connect(bus);
s.start(t, Math.random());
s.stop(t + dur + 0.05);
}
function N(m) {
return 440 * Math.pow(2, (m - 69) / 12)
}
function rnd(a, b) {
return a + Math.random() * (b - a)
}
function pk(a) {
return a[(Math.random() * a.length) | 0]
}
function pluck(m, t, d, v) {
osc('triangle', N(m), t, d, v);
osc('sine', N(m + 12), t, d * 0.5, v * 0.35);
}
function piano(m, t, d, v) {
osc('triangle', N(m), t, d, v, {
a: .005
});
osc('sine', N(m), t, d * 1.2, v * .6);
osc('sine', N(m + 19), t, d * .3, v * .08);
}
function pad(ms, t, d, v, lp) {
ms.forEach(function(m) {
[-8, 8].forEach(function(dt) {
osc('sawtooth', N(m), t, d, v, {
a: Math.min(1.2, d * 0.3),
det: dt,
lp: lp || 900
});
});
});
}
function kick(t, v) {
osc('sine', 150, t, 0.38, v || 0.9, {
to: 42,
toT: 0.3
});
}
function snare(t, v) {
nz(t, 0.18, v || 0.3, 'highpass', 1800);
osc('triangle', 190, t, 0.1, 0.15);
}
function hat(t, v) {
nz(t, 0.05, v || 0.1, 'highpass', 8000);
}
function tom(t, f, v) {
osc('sine', f, t, 0.5, v || 0.6, {
to: f * 0.55
});
nz(t, 0.08, 0.15, 'bandpass', f * 3);
}
function taiko(t, v) {
osc('sine', 70, t, 0.9, v || 1, {
to: 40
});
nz(t, 0.2, 0.4, 'lowpass', 400);
}
var music = {
uke: function(t) {
var ch = [[60, 64, 67, 72], [55, 59, 62, 67], [57, 60, 64, 69], [53, 57, 60, 65]],
b = 0.3125;
for (var i = 0; i < 32; i++) {
var c = ch[Math.floor(i / 8) % 4];
pluck(c[[0, 2, 1, 3, 2, 1, 3, 2][i % 8]], t + i * b, 0.5, 0.07);
if (i % 2)
hat(t + i * b, 0.03);
}
for (var j = 0; j < 4; j++)
pluck(ch[j][0] - 12, t + j * 2.5, 1.2, 0.09);
},
savanna: function(t) {
[[50, 57, 62, 65], [46, 53, 58, 62], [53, 57, 60, 65], [48, 55, 60, 64]].forEach(function(c, i) {
pad(c, t + i * 2.5, 2.6, 0.02, 800);
});
for (var i = 0; i = 0)
tom(t + i * 0.5, i % 8 === 0 ? 110 : 160, 0.35);
}
[74, 72, 69, 74, 77, 76, 74].forEach(function(m, i) {
osc('sine', N(m), t + 4.6 + i * 0.55, 0.6, 0.07, {
a: .06
});
});
},
gentle: function(t) {
pad([60, 64, 67], t, 5, 0.014, 700);
pad([57, 60, 64], t + 5, 5, 0.014, 700);
[72, 74, 76, 79, 76, 74, 72, 67, 69, 72, 74, 72].forEach(function(m, i) {
pluck(m, t + i * 0.8, 0.9, 0.05);
});
},
space: function(t) {
pad([50, 57, 62, 69], t, 10, 0.016, 600);
for (var i = 0; i < 14; i++)
osc('sine', N(pk([74, 76, 79, 81, 83, 86])), t + i * 0.7 + Math.random() * 0.2, 0.9, 0.035, {
a: .01
});
},
ad: function(t) {
var b = 0.5;
for (var i = 0; i < 20; i++) {
kick(t + i * b, 0.7);
hat(t + i * b + b / 2, 0.08);
if (i % 2)
snare(t + i * b, 0.2);
pluck([45, 45, 48, 43][Math.floor(i / 4) % 4], t + i * b, 0.4, 0.12);
}
var st = [[69, 72, 76], [69, 72, 76], [72, 76, 79], [67, 71, 74]];
for (var j = 0; j < 5; j++)
st[j % 4].forEach(function(m) {
pluck(m, t + j * 2 + 0.25, 0.25, 0.05);
});
},
twinkle: function(t) {
var mel = [60, 60, 67, 67, 69, 69, 67, 65, 65, 64, 64, 62, 62, 60],
d = [.6, .6, .6, .6, .6, .6, 1.2, .6, .6, .6, .6, .6, .6, 1.2],
tt = t + 0.4,
bass = [48, 48, 53, 48, 53, 48, 55, 48];
mel.forEach(function(m, i) {
piano(m + 12, tt, d[i] * 0.95, 0.16);
if (i % 2 === 0)
piano(bass[Math.floor(i / 2) % 8], tt, d[i] * 1.6, 0.07);
tt += d[i];
});
for (var k = 0; k < 16; k++)
osc('sine', N(pk([84, 88, 91])), t + k * 0.6, 0.3, 0.015);
},
dance: function(t) {
var b = 60 / 124;
for (var i = 0; i < 20; i++) {
kick(t + i * b, 0.8);
hat(t + i * b + b / 2, 0.1);
if (i % 2)
snare(t + i * b, 0.25);
pluck([40, 40, 43, 38][Math.floor(i / 4) % 4], t + i * b + b / 2, 0.3, 0.14);
}
for (var j = 0; j < 10; j++)
[64, 67, 71].forEach(function(m) {
pluck(m + (j % 4 === 2 ? -2 : 0), t + j * 2 * b + b, 0.2, 0.04);
});
},
dark: function(t) {
osc('sawtooth', N(33), t, 10, 0.08, {
a: 2,
lp: 220
});
osc('sawtooth', N(40), t + 3, 7, 0.05, {
a: 2,
lp: 260
});
[0, 4.8, 6.9].forEach(function(x) {
taiko(t + x, 0.7);
});
[62, 60, 57].forEach(function(m, i) {
osc('sine', N(m), t + 4 + i * 1.2, 1.4, 0.03, {
a: .3
});
});
},
war: function(t) {
osc('sawtooth', N(36), t, 10, 0.07, {
a: 1.5,
lp: 240
});
for (var i = 0; i = 0)
taiko(t + i * 0.5, i % 8 === 0 ? 0.9 : 0.5);
}
[57, 60, 62, 64, 62, 60].forEach(function(m, i) {
osc('sawtooth', N(m), t + 6 + i * 0.6, 0.7, 0.025, {
a: .15,
lp: 1200
});
});
},
pop: function(t) {
var b = 0.4;
for (var i = 0; i < 25; i++) {
if (i % 2 === 0)
kick(t + i * b, 0.4);
hat(t + i * b + b / 2, 0.05);
pluck([72, 76, 79, 76, 74, 77, 81, 77][i % 8], t + i * b, 0.3, 0.05);
}
},
logo: function(t) {
pad([48, 55, 60, 64], t + 1.9, 5, 0.022, 1500);
}
};
var fx = {
whoosh: function(t) {
nz(t, 0.55, 0.35, 'bandpass', 300, {
to: 3500,
q: 1.2,
a: .2
});
},
thud: function(t) {
kick(t, 1);
nz(t, 0.15, 0.3, 'lowpass', 300);
},
splash: function(t) {
nz(t, 0.9, 0.5, 'bandpass', 1800, {
to: 500,
q: .8
});
for (var i = 0; i < 6; i++)
osc('sine', rnd(600, 1400), t + i * 0.06, 0.12, 0.08, {
to: rnd(300, 500)
});
},
chime: function(t) {
[88, 91, 96].forEach(function(m, i) {
osc('sine', N(m), t + i * 0.07, 1.4, 0.09);
});
},
roar: function(t) {
nz(t, 1.3, 0.7, 'lowpass', 700, {
to: 250,
a: .15
});
osc('sawtooth', 120, t, 1.2, 0.22, {
to: 80,
a: .1,
lp: 600
});
osc('sawtooth', 90, t, 1.3, 0.18, {
to: 60,
a: .1,
lp: 400
});
},
flap: function(t) {
for (var i = 0; i < 8; i++)
nz(t + i * 0.09, 0.07, 0.12, 'bandpass', 900);
},
chirp: function(t) {
for (var i = 0; i < 3; i++)
osc('sine', 3200, t + i * 0.13, 0.09, 0.06, {
to: 4600
});
},
sneeze: function(t) {
nz(t, 0.12, 0.15, 'bandpass', 900, {
a: .1
});
nz(t + 0.25, 0.35, 0.5, 'highpass', 1500);
osc('triangle', 500, t + 0.25, 0.2, 0.1, {
to: 250
});
},
beep: function(t) {
osc('square', 880, t, 0.09, 0.06);
osc('square', 1320, t + 0.12, 0.09, 0.06);
},
thunder: function(t) {
nz(t, 0.25, 0.9, 'lowpass', 2000, {
to: 400
});
nz(t + 0.1, 2.6, 0.8, 'lowpass', 300, {
to: 60,
a: .05
});
},
rain: function(t) {
nz(t, 10, 0.12, 'highpass', 1200, {
a: .5
});
nz(t, 10, 0.06, 'bandpass', 500, {
a: .5
});
},
swordring: function(t) {
osc('triangle', 1800, t, 1.4, 0.08);
osc('sine', 2650, t, 1.0, 0.05);
nz(t, 0.1, 0.2, 'highpass', 4000);
},
arrow: function(t) {
nz(t, 0.4, 0.35, 'bandpass', 2200, {
to: 700,
q: 3,
a: .02
});
osc('triangle', 90, t, 0.12, 0.2);
},
squeak: function(t, d) {
var dd = Math.min(d || 0.6, 1.4);
nz(t, dd, 0.05, 'bandpass', rnd(2400, 3200), {
q: 6,
a: .03
});
},
boing: function(t) {
osc('sine', 220, t, 0.3, 0.25, {
to: 520
});
},
kickball: function(t) {
kick(t, 0.7);
nz(t, 0.06, 0.3, 'bandpass', 1200);
},
step: function(t) {
nz(t, 0.05, 0.09, 'lowpass', 500);
},
cheer: function(t) {
nz(t, 1.6, 0.25, 'bandpass', 1200, {
q: .6,
a: .3
});
},
pop: function(t) {
osc('sine', 500, t, 0.12, 0.25, {
to: 1300
});
},
tick: function(t) {
osc('square', 2000, t, 0.03, 0.03);
},
bass: function(t) {
osc('sine', 60, t, 0.6, 0.7, {
to: 40
});
},
shimmer: function(t) {
for (var i = 0; i < 8; i++)
osc('sine', N(84 + i * 2), t + i * 0.04, 0.5, 0.03);
}
};
return {
setActive: function(on) {
active = on;
if (on)
ac();
else if (ctx)
newBus();
},
setMuted: function(m) {
muted = m;
if (ctx)
newBus();
},
isMuted: function() {
return muted
},
live: function() {
return active && !muted && !!ctx;
},
play: function(name, arg) {
if (!this.live())
return;
var t = ctx.currentTime + 0.03;
if (name === 'music') {
if (music[arg])
music[arg](t);
} else if (fx[name])
fx[name](t, arg);
}
};
})();
window.SFX = SFX;
/* ===== 2D film engine (SVG, 8\u201310 s loops) ===== */
function seg(t, a, b) {
return Math.max(0, Math.min(1, (t - a) / (b - a)))
}
function ease(x) {
return x = 0)
running2D.splice(i, 1);
}
(function loop() {
requestAnimationFrame(loop);
var now = performance.now() / 1000;
running2D.forEach(function(o) {
var r = o.el.getBoundingClientRect();
if (r.bottom innerHeight || r.width < 2)
return;
var D = o.f.D || 10,
t = (now - o.start) % D;
if (o.sound && SFX.live() && o.f.cues)
o.f.cues.forEach(function(c) {
if ((o.prev = c[0]) || (t o.prev || c[0] <= t)))
SFX.play(c[1], c[2]);
});
o.prev = t;
o.f.update(t);
var tile = o.el.closest('.tile,.lb-box');
if (tile)
tile.style.setProperty('--p', (t / D).toFixed(3));
});
})();
/* --- whiteboard --- */
function circ(x, y, r) {
return 'M' + (x - r) + ' ' + y + ' a' + r + ' ' + r + ' 0 1 0 ' + (2 * r) + ' 0 a' + r + ' ' + r + ' 0 1 0 ' + (-2 * r) + ' 0 '
}
function fig(x, y, s) {
var r = 12 * s;
return circ(x, y, r) + 'M' + x + ' ' + (y + r) + ' V' + (y + 50 * s) + ' M' + x + ' ' + (y + 22 * s) + ' L' + (x - 18 * s) + ' ' + (y + 40 * s) + ' M' + x + ' ' + (y + 22 * s) + ' L' + (x + 18 * s) + ' ' + (y + 40 * s) + ' M' + x + ' ' + (y + 50 * s) + ' L' + (x - 14 * s) + ' ' + (y + 80 * s) + ' M' + x + ' ' + (y + 50 * s) + ' L' + (x + 14 * s) + ' ' + (y + 80 * s) + ' ';
}
var HAND = '' +
'' +
'' +
'';
function WB(spec) {
return function(el) {
el.innerHTML = '' + HAND + '';
var svg = el.firstChild,
defs = svg.firstChild,
all = svg.querySelector('.wb-all'),
hand = svg.querySelector('.wb-hand'),
steps = [],
cues = [[0, 'music', 'uke']];
var scenes = spec.map(function(sc) {
var g = document.createElementNS(NS, 'g');
all.appendChild(g);
var at = sc.start,
S = {
g: g,
wipe: sc.wipe
};
sc.steps.forEach(function(st) {
var o = {
at: at,
dur: st.dur
};
if (st.d) {
if (st.fill) {
var f = document.createElementNS(NS, 'path');
f.setAttribute('d', st.d);
f.setAttribute('fill', st.fill);
f.setAttribute('opacity', 0);
g.appendChild(f);
o.fillEl = f;
o.fo = st.fo || 0.45;
}
var p = document.createElementNS(NS, 'path');
p.setAttribute('d', st.d);
p.setAttribute('fill', 'none');
p.setAttribute('stroke', st.c || '#1c1c28');
p.setAttribute('stroke-width', st.w || 4);
p.setAttribute('stroke-linecap', 'round');
p.setAttribute('stroke-linejoin', 'round');
g.appendChild(p);
o.el = p;
o.len = p.getTotalLength() || 1;
p.style.strokeDasharray = o.len + ' ' + o.len;
p.style.strokeDashoffset = o.len;
o.type = 'p';
}
else {
var id = uid(),
cp = document.createElementNS(NS, 'clipPath');
cp.setAttribute('id', id);
var rr = document.createElementNS(NS, 'rect');
rr.setAttribute('x', st.x - 6);
rr.setAttribute('y', st.y - st.s * 1.1);
rr.setAttribute('height', st.s * 1.6);
rr.setAttribute('width', 0);
cp.appendChild(rr);
defs.appendChild(cp);
var tx = document.createElementNS(NS, 'text');
tx.setAttribute('x', st.x);
tx.setAttribute('y', st.y);
tx.setAttribute('class', 'wbtx');
tx.setAttribute('font-size', st.s);
tx.setAttribute('fill', st.c || '#1c1c28');
tx.setAttribute('clip-path', 'url(#' + id + ')');
tx.textContent = st.t;
g.appendChild(tx);
o.el = tx;
o.rect = rr;
o.x = st.x;
o.y = st.y;
o.s = st.s;
o.type = 't';
}
steps.push(o);
cues.push([at, 'squeak', st.dur]);
at += st.dur + 0.08;
});
if (sc.wipe != null)
cues.push([sc.wipe, 'whoosh']);
return S;
});
function wlen(o) {
if (!o.ok) {
var w = 0;
try {
w = o.el.getComputedTextLength();
} catch (e) {}
o.w = w || o.s * 0.48 * o.el.textContent.length;
if (document.fonts && document.fonts.status === 'loaded' && w)
o.ok = true;
}
return o.w;
}
function pt(o, p) {
if (o.type === 'p')
return o.el.getPointAtLength(o.len * p);
return {
x: o.x + wlen(o) * p,
y: o.y - o.s * 0.3 + Math.sin(p * 70) * o.s * 0.12
};
}
var hx = 640,
hy = 420;
return {
D: 10,
cues: cues,
update: function(t) {
all.style.opacity = t > 9.55 ? (1 - seg(t, 9.55, 9.95)).toFixed(3) : 1;
scenes.forEach(function(S) {
var off = S.wipe != null ? -760 * ease(seg(t, S.wipe, S.wipe + 0.55)) : 0;
S.g.setAttribute('transform', 'translate(' + off.toFixed(1) + ',0)');
});
var target = null;
steps.forEach(function(o) {
var p = seg(t, o.at, o.at + o.dur);
if (o.type === 'p') {
o.el.style.strokeDashoffset = (o.len * (1 - p)).toFixed(2);
o.el.style.visibility = p > 0 ? 'visible' : 'hidden';
if (o.fillEl)
o.fillEl.setAttribute('opacity', (seg(t, o.at + o.dur, o.at + o.dur + 0.35) * o.fo).toFixed(3));
}
else
o.rect.setAttribute('width', ((wlen(o) + 14) * p).toFixed(1));
if (t >= o.at && t S.wipe && t < S.wipe + 0.55)
wiping = S;
});
var nxt = null;
for (var i = 0; i t) {
nxt = steps[i];
break;
}
}
if (wiping)
target = {
x: lerp(640, -60, seg(t, wiping.wipe, wiping.wipe + 0.55)),
y: 210
};
else if (nxt && nxt.at - t < 0.5)
target = pt(nxt, 0);
else
target = {
x: 600,
y: 395,
rest: 1
};
}
var k = target.rest ? 0.07 : 0.4;
hx += (target.x - hx) * k;
hy += (target.y - hy) * k;
hand.setAttribute('transform', 'translate(' + hx.toFixed(1) + ',' + hy.toFixed(1) + ')');
}
};
};
}
F2D.wb1 = WB([
{
start: .25,
wipe: 4.85,
steps: [{
t: 'Pay anyone in 2 seconds',
x: 40,
y: 62,
s: 42,
dur: .85
},
{
d: 'M104 100 H176 Q190 100 190 114 V286 Q190 300 176 300 H104 Q90 300 90 286 V114 Q90 100 104 100 Z M125 115 H155',
dur: .7,
fill: '#118AB2',
fo: .18
},
{
d: 'M108 150 h28 v28 h-28 Z M144 150 h28 v28 h-28 Z M108 186 h28 v28 h-28 Z M150 192 h8 v8 h-8 Z M162 204 h8 v8 h-8 Z M150 214 h8',
dur: .5,
w: 3
},
{
t: '\u20b9',
x: 128,
y: 268,
s: 36,
c: '#06A77D',
dur: .2
},
{
d: 'M215 200 C 270 140 340 140 390 190 M376 178 L392 192 L372 198',
c: '#EF476F',
dur: .5
},
{
d: 'M420 180 H600 V300 H420 Z M410 180 L432 130 H588 L610 180 M490 300 V240 H530 V300',
dur: .65,
fill: '#FFD166',
fo: .4
},
{
d: 'M452 130 L444 180 M484 130 L480 180 M516 130 V180 M548 130 L552 180',
c: '#EF476F',
dur: .35
}]
},
{
start: 5.5,
steps: [{
d: circ(320, 150, 58),
c: '#06A77D',
w: 5,
dur: .6,
fill: '#06D6A0',
fo: .25
}, {
d: 'M292 152 L314 176 L352 128',
c: '#06A77D',
w: 8,
dur: .35
},
{
t: 'Paid!',
x: 282,
y: 250,
s: 46,
c: '#06A77D',
dur: .4
}, {
t: 'Fast. Safe. Simple.',
x: 178,
y: 318,
s: 40,
dur: .9
},
{
d: 'M70 250 a34 11 0 1 0 68 0 a34 11 0 1 0 -68 0 M70 250 v18 a34 11 0 0 0 68 0 v-18 M70 268 v18 a34 11 0 0 0 68 0 v-18',
c: '#B5651D',
dur: .6,
fill: '#FFD166',
fo: .55
},
{
d: 'M520 120 l0 24 M508 132 l24 0 M560 170 l0 16 M552 178 l16 0',
c: '#FFB703',
dur: .3
}]
}
]);
F2D.wb2 = WB([
{
start: .25,
steps: [{
t: 'Life gets rainy sometimes\u2026',
x: 40,
y: 60,
s: 40,
dur: .9
},
{
d: 'M462 102 C438 102 436 74 458 70 C462 48 496 44 506 64 C522 52 548 62 544 82 C562 84 562 104 544 104 Z',
dur: .55,
fill: '#B8C4D6',
fo: .6
},
{
d: 'M470 118 l-6 16 M500 118 l-6 16 M530 118 l-6 16 M485 140 l-6 14 M515 140 l-6 14',
c: '#118AB2',
dur: .4,
w: 3
},
{
d: fig(455, 215, 1) + fig(545, 215, 1) + fig(500, 240, .7),
dur: 1.2
}]
},
{
start: 4.9,
steps: [{
d: 'M400 190 Q500 100 600 190 Q583 177 567 190 Q550 177 533 190 Q517 177 500 190 Q483 177 467 190 Q450 177 433 190 Q417 177 400 190 Z M500 190 V205',
c: '#C9184A',
dur: .8,
fill: '#EF476F',
fo: .4
},
{
d: 'M140 262 C 70 214 84 160 140 188 C 196 160 210 214 140 262 Z',
c: '#C9184A',
dur: .6,
fill: '#EF476F',
fo: .3
},
{
d: 'M100 212 H120 L128 194 L140 232 L150 204 H180',
c: '#C9184A',
dur: .4,
w: 3
},
{
t: 'Protect what matters most.',
x: 40,
y: 330,
s: 38,
dur: 1.0
}]
}
]);
F2D.wb3 = WB([
{
start: .25,
wipe: 4.85,
steps: [{
t: 'Your roof can pay your bills',
x: 40,
y: 60,
s: 40,
dur: .95
},
{
d: circ(110, 160, 30),
c: '#E76F51',
dur: .4,
fill: '#FFD166',
fo: .75
},
{
d: 'M110 114 v-14 M110 206 v14 M64 160 h-14 M156 160 h14 M78 128 l-10 -10 M142 128 l10 -10 M78 192 l-10 10 M142 192 l10 10',
c: '#E76F51',
dur: .35
},
{
d: 'M330 300 V205 H530 V300 Z',
dur: .45,
fill: '#FFE8D6',
fo: .8
}, {
d: 'M310 210 L430 122 L550 210',
dur: .35
}, {
d: 'M410 300 V248 H450 V300 M352 228 H392 V264 H352 Z',
dur: .35
},
{
d: 'M440 140 L486 172 L470 184 L424 152 Z M490 175 L530 203 L514 214 L474 187 Z',
c: '#073B4C',
dur: .4,
fill: '#118AB2',
fo: .65
},
{
d: 'M160 140 C 250 90 360 98 425 140 M410 128 L427 141 L407 146',
c: '#FFB703',
dur: .45
}]
},
{
start: 5.5,
steps: [{
d: 'M90 110 H230 L260 140 V300 H90 Z M230 110 V140 H260 M110 160 H230 M110 185 H230 M110 210 H200',
dur: .7
},
{
t: '\u20b9',
x: 120,
y: 272,
s: 48,
c: '#EF476F',
dur: .2
},
{
d: 'M320 300 H580 M332 300 V170 H372 V300 M394 300 V205 H434 V300 M456 300 V240 H496 V300 M518 300 V268 H558 V300',
c: '#073B4C',
dur: .7,
fill: '#06D6A0',
fo: .25
},
{
d: 'M340 140 C 420 160 480 200 545 235 M528 238 L547 236 L540 218',
c: '#06A77D',
w: 5,
dur: .45
},
{
t: 'Save on every bill',
x: 300,
y: 110,
s: 42,
c: '#06A77D',
dur: .8
}]
}
]);
F2D.wb4 = WB([
{
start: .25,
wipe: 4.85,
steps: [{
t: 'Learn anywhere, anytime',
x: 40,
y: 60,
s: 40,
dur: .9
},
{
d: 'M150 120 H390 V270 H150 Z',
dur: .55,
fill: '#E0F2FE',
fo: .9
}, {
d: 'M120 270 H420 L440 296 H100 Z',
dur: .35,
fill: '#CBD5E1',
fo: .7
},
{
d: 'M250 165 L310 195 L250 225 Z',
c: '#EF476F',
dur: .35,
fill: '#EF476F',
fo: .6
},
{
d: 'M470 165 L540 135 L610 165 L540 195 Z M500 178 V215 Q540 238 580 215 V178 M610 165 V205',
dur: .7,
fill: '#1D3557',
fo: .75
},
{
d: 'M610 205 l-6 18 M610 205 l6 18',
c: '#FFB703',
dur: .15
}]
},
{
start: 5.5,
steps: [{
d: 'M80 310 H180 V270 H280 V230 H380 V190 H480 V150 H580',
c: '#073B4C',
w: 5,
dur: .8
},
{
d: 'M560 150 V80 M560 80 L600 92 L560 104',
c: '#EF476F',
dur: .4
},
{
d: fig(330, 160, .75),
dur: .55
}, {
t: 'Grow your career',
x: 60,
y: 118,
s: 46,
c: '#1D3557',
dur: .8
},
{
d: 'M610 56 l0 16 M602 64 l16 0',
c: '#FFB703',
dur: .2
}]
}
]);
/* --- 2D character short: "Goal!" --- */
F2D.park = function(el) {
var u = uid();
var conf = '';
var cols = ['#FF5A5F', '#FFC23C', '#2EC4B6', '#7B5CFF', '#4CC9F0', '#FF8FB1'];
for (var i = 0; i < 28; i++)
conf += '';
el.innerHTML = '' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'' +
'GOAL!' +
'' + conf + '';
var q = function(s) {
return el.querySelector(s)
},
kid = q('.pk-kid'),
body = q('.pk-body'),
lA = q('.pk-legA'),
lB = q('.pk-legB'),
aA = q('.pk-armA'),
aB = q('.pk-armB'),
eye = q('.pk-eye'),
ball = q('.pk-ball'),
bsh = q('.pk-bsh'),
txt = q('.pk-txt'),
allG = q('.pk-all'),
far = q('.pk-far'),
cl = q('.pk-cl'),
cf = [].slice.call(el.querySelectorAll('.pk-cf')),
ksh = q('.pk-ksh');
var cfd = cf.map(function() {
return {
x: Math.random() * 640,
v: 80 + Math.random() * 120,
r: Math.random() * 360,
s: Math.random() * 400 - 200,
d: Math.random() * 0.5
}
});
var cues = [[0, 'music', 'pop'], [3.47, 'boing'], [4.03, 'boing'], [4.55, 'boing'], [4.75, 'kickball'], [5.6, 'cheer'], [5.62, 'chime'], [5.65, 'pop']];
for (var s = 0.35; s 0.2 && t 3.0 && t 4.25 && t < 4.95) {
legA = t < 4.6 ? lerp(0, 40, seg(t, 4.25, 4.6)) : t 5.6 && t < 8.6) {
var c = (t - 5.6) * 2.2;
jy = -Math.abs(Math.sin(c * Math.PI)) * 36;
armA = -160 + Math.sin(t * 20) * 10;
armB = -150 + Math.sin(t * 20 + 1) * 10;
legA = Math.sin(c * Math.PI) * -20;
legB = -legA;
}
var bob = walking ? Math.abs(Math.cos(t * Math.PI * 2 * 1.85)) * -3 : 0;
kid.setAttribute('transform', 'translate(' + kx.toFixed(1) + ',284) scale(1.55)');
body.setAttribute('transform', 'translate(0,' + (jy + bob).toFixed(1) + ')');
ksh.setAttribute('transform', 'scale(' + (1 + jy / 120).toFixed(2) + ',1)');
R(lA, legA, 0, -38);
R(lB, legB, 0, -38);
R(aA, armA, 0, -62);
R(aB, armB, 0, -62);
eye.setAttribute('transform', (t % 3.2) = 2.9 && t = 4.6 && t = 4.75 && t = 5.55) {
var p3 = seg(t, 5.55, 6.1);
bx = 612 + p3 * 6;
by = lerp(236, 270, p3) - Math.sin(p3 * Math.PI) * 12;
br = 900;
}
ball.setAttribute('transform', 'translate(' + bx.toFixed(1) + ',' + by.toFixed(1) + ') rotate(' + br.toFixed(0) + ')');
bsh.setAttribute('cx', bx.toFixed(1));
bsh.setAttribute('rx', (13 * (1 - (270 - by) / 220)).toFixed(1));
var gq = seg(t, 5.6, 5.95),
gs = gq 5.6 ? 1 - seg(t, 9.0, 9.4) : 0).toFixed(2));
txt.setAttribute('transform', 'translate(400,130) scale(' + (t > 5.6 ? gs : 0).toFixed(3) + ') rotate(' + (Math.sin(t * 6) * 4).toFixed(1) + ') translate(-400,-130)');
far.setAttribute('transform', 'translate(' + (-seg(t, 0.2, 3.0) * 60).toFixed(1) + ',0)');
cl.setAttribute('transform', 'translate(' + (-t * 14).toFixed(1) + ',0)');
cf.forEach(function(r, i) {
var d = cfd[i],
tt = t - 5.6 - d.d;
if (tt < 0) {
r.setAttribute('opacity', 0);
return;
}
r.setAttribute('opacity', 1 - seg(t, 9, 9.5));
r.setAttribute('transform', 'translate(' + (d.x + Math.sin(tt * 3 + i) * 20).toFixed(1) + ',' + (-20 + tt * d.v).toFixed(1) + ') rotate(' + (d.r + tt * d.s).toFixed(0) + ')');
});
}
};
};
/* --- logo sting --- */
F2D.logo = function(el) {
var u = uid(),
letters = 'DUTTA INNOVATIONS'.split(''),
ts = '';
letters.forEach(function(ch) {
ts += '' + (ch === ' ' ? '\u00a0' : ch) + '';
});
var dots = '';
for (var i = 0; i < 36; i++)
dots += '';
el.innerHTML = '' +
'' +
'' + dots +
'' +
'' +
'' + ts + '' +
'ANIMATION STUDIO' +
'';
var q = function(s) {
return el.querySelector(s)
},
s1 = q('.lg-s1'),
s2 = q('.lg-s2'),
s3 = q('.lg-s3'),
mark = q('.lg-mark'),
eyes = q('.lg-eyes'),
tsp = [].slice.call(el.querySelectorAll('.lg-t tspan')),
tag = q('.lg-tag'),
sw = q('.lg-sw'),
all = q('.lg-all'),
dd = [].slice.call(el.querySelectorAll('.lg-d'));
var dp = dd.map(function() {
var a = Math.random() * 6.28,
r = 260 + Math.random() * 120;
return {
x: 320 + Math.cos(a) * r,
y: 150 + Math.sin(a) * r,
a: a,
o: Math.random()
}
});
var cues = [[0, 'music', 'logo'], [0.3, 'whoosh'], [0.85, 'pop'], [1.1, 'pop'], [1.35, 'pop'], [1.95, 'chime'], [4.8, 'shimmer']];
for (var i = 0; i 0 ? 1 : 0) * (1 - sh);
el2.setAttribute('transform', 'translate(' + x.toFixed(1) + ',' + y.toFixed(1) + ') rotate(' + ((1 - e) * rot).toFixed(0) + ') scale(' + s.toFixed(3) + ')');
}
return {
D: 8,
cues: cues,
update: function(t) {
all.style.opacity = Math.min(seg(t, 0, 0.25), 1 - seg(t, 7.4, 7.95)).toFixed(3);
fly(s1, t, 0.3, -40, -40, 270, 150, -200);
fly(s2, t, 0.55, 680, -40, 320, 150, 220);
fly(s3, t, 0.8, 320, 420, 370, 150, -180);
var mp = seg(t, 1.75, 2.25),
ms = mp 0 ? ms : 0).toFixed(3) + ') rotate(' + (Math.sin(t * 2) * 2).toFixed(1) + ')');
eyes.setAttribute('transform', (t > 3.1 && t 5.9 && t < 6.02) ? 'scale(1,.12)' : '');
tsp.forEach(function(sp, i) {
var p = seg(t, 2.6 + i * 0.07, 2.95 + i * 0.07);
sp.setAttribute('fill-opacity', p.toFixed(2));
sp.setAttribute('dy', i === 0 ? 0 : 0);
});
q('.lg-t').setAttribute('transform', 'translate(0,' + ((1 - seg(t, 2.6, 3.9)) * 14).toFixed(1) + ')');
tag.setAttribute('opacity', seg(t, 4.0, 4.6).toFixed(2));
tag.setAttribute('letter-spacing', lerp(14, 7, ease(seg(t, 4, 4.8))).toFixed(1));
sw.setAttribute('x', lerp(-160, 820, seg(t, 4.8, 5.7)).toFixed(0));
dd.forEach(function(c, i) {
var d = dp[i],
p = ease(seg(t, 0, 2.0)),
r = lerp(1, 0.25, p) * (1 + 0.1 * Math.sin(t * 2 + i));
var x = 320 + (d.x - 320) * r + Math.sin(t + i) * 10 * p,
y = 150 + (d.y - 150) * r + Math.cos(t * 1.3 + i) * 8 * p;
c.setAttribute('cx', x.toFixed(1));
c.setAttribute('cy', y.toFixed(1));
c.setAttribute('opacity', (0.3 + 0.7 * Math.abs(Math.sin(t * 2 + d.o * 6))).toFixed(2));
});
}
};
};
/* --- kinetic typography ad --- */
F2D.kinetic = function(el) {
var cards = [{
t: 0,
bg: '#FFC23C',
fg: '#1B1340',
txt: 'Your brand',
s: 70
}, {
t: 1.6,
bg: '#7B5CFF',
fg: '#fff',
txt: 'deserves',
s: 70
}, {
t: 3.2,
bg: '#FF5A5F',
fg: '#fff',
txt: 'MOTION.',
s: 118,
shake: 1
}, {
t: 4.8,
bg: '#2EC4B6',
fg: '#1B1340',
txt: 'that sells.',
s: 70
}, {
t: 6.4,
bg: '#1B1340',
fg: '#FFC23C',
txt: '2D \u00b7 3D \u00b7 AI',
s: 66
}, {
t: 8.0,
bg: '#FFF7EC',
fg: '#1B1340',
txt: 'DUTTA INNOVATIONS',
s: 42,
sub: 'Animation Studio \u00b7 Ads that move'
}];
var h = '';
cards.forEach(function(c, i) {
h += '' + c.txt + '' + (c.sub ? '' + c.sub + '' : '') + '';
});
h += '';
el.innerHTML = h;
var gs = [].slice.call(el.querySelectorAll('.kn-c')),
all = el.querySelector('.kn-all');
var cues = [[0, 'music', 'ad'], [8.0, 'chime']];
cards.forEach(function(c) {
cues.push([c.t, 'whoosh']);
cues.push([c.t + 0.18, 'bass']);
});
return {
D: 10,
cues: cues,
update: function(t) {
all.style.opacity = (1 - seg(t, 9.6, 10)).toFixed(3);
gs.forEach(function(g, i) {
var c = cards[i],
on = t >= c.t;
g.style.display = on ? '' : 'none';
if (!on)
return;
g.firstChild.setAttribute('r', (760 * ease(seg(t, c.t, c.t + 0.4))).toFixed(0));
var q = seg(t, c.t + 0.12, c.t + 0.42),
s = lerp(2.6, 1, 1 - Math.pow(1 - q, 3)),
ox = 0,
oy = 0;
if (c.shake && t < c.t + 1.5) {
ox = (Math.random() - .5) * 8 * seg(t, c.t + 0.4, c.t + 0.5);
oy = (Math.random() - .5) * 8 * seg(t, c.t + 0.4, c.t + 0.5);
}
var drift = (t - c.t) * 6;
g.lastChild.setAttribute('transform', 'translate(' + (320 + ox + drift).toFixed(1) + ',' + (180 + oy).toFixed(1) + ') scale(' + s.toFixed(3) + ') translate(-320,-180)');
g.lastChild.setAttribute('opacity', q.toFixed(2));
});
}
};
};
/* --- voiceover reel --- */
F2D.vo = function(el) {
var u = uid(),
bars = '';
for (var i = 0; i < 56; i++)
bars += '';
el.innerHTML = '' +
'' +
'' +
'' + bars + '' +
'REC00:00:00' +
'' +
'';
var B = [].slice.call(el.querySelectorAll('.vo-b')),
txt = el.querySelector('.vo-txt'),
tc = el.querySelector('.vo-tc'),
rec = el.querySelector('.vo-rec'),
ring = el.querySelector('.vo-ring'),
lg = el.querySelector('.vo-langs');
var lines = [['\u0928\u092e\u0938\u094d\u0924\u0947! \u0906\u092a\u0915\u0940 \u0915\u0939\u093e\u0928\u0940, \u0939\u092e\u093e\u0930\u0940 \u0906\u0935\u093e\u091c\u093c\u0964', 'HINDI'], ['Hello! Your story, in our voice.', 'ENGLISH'], ['Hi friends! Chalo, ek nayi kahani! \ud83c\udf88', 'KIDS \u00b7 HINGLISH']];
return {
D: 10,
cues: [],
update: function(t) {
var li = Math.min(2, Math.floor(t / 3.3)),
lt = t - li * 3.3,
L = lines[li][0],
n = Math.floor(seg(lt, 0.2, 2.3) * L.length),
speaking = lt > 0.2 && lt < 2.6;
txt.textContent = Array.from(L).slice(0, Math.ceil(n * Array.from(L).length / L.length)).join('');
lg.innerHTML = '' + lines[li][1] + '';
B.forEach(function(b, i) {
var v = Math.abs(Math.sin(t * 7.3 + i * 0.5) * Math.sin(t * 3.1 + i * 0.21)) * (speaking ? 1 : 0.12) + 0.04 + Math.abs(Math.sin(t * 17 + i)) * 0.08 * (speaking ? 1 : 0);
var hh = (v * 110).toFixed(1);
b.setAttribute('height', hh);
b.setAttribute('y', (180 - v * 55).toFixed(1));
});
var s = Math.floor(t),
f = Math.floor((t % 1) * 25);
tc.textContent = '00:00:' + (s < 10 ? '0' : '') + s + ':' + (f < 10 ? '0' : '') + f;
rec.setAttribute('opacity', (t % 1) < 0.5 ? 1 : 0.25);
ring.setAttribute('r', (40 + (speaking ? Math.abs(Math.sin(t * 9)) * 8 : 0)).toFixed(1));
ring.setAttribute('opacity', speaking ? 0.8 : 0.25);
}
};
};
/* ===== portfolio ===== */
/* REPLACE WITH YOUR REAL WORK: add src:'https://\u2026/file.mp4' (or .webm/.gif) to any item and that tile will play
your real video (with its own sound in the player). Items without src play the built-in animated film.
f = built-in film ('3d:savanna','3d:warrior','2d:wb1' \u2026), c = category: 3D, AI, Whiteboard, 2D, Ads, Kids, Voiceover */
CONFIG.portfolio = [
{
t: 'Savanna \u2014 3D animated short',
c: '3D',
f: '3d:savanna',
src: ''
},
{
t: 'The Last Guardian \u2014 AI film glimpse',
c: 'AI',
f: '3d:warrior',
src: ''
},
{
t: 'UPI payments \u2014 whiteboard explainer',
c: 'Whiteboard',
f: '2d:wb1',
src: ''
},
{
t: 'Twinkle Twinkle \u2014 3D nursery rhyme',
c: 'Kids',
f: '3d:twinkle',
src: ''
},
{
t: 'Mango Fizz \u2014 3D product ad',
c: 'Ads',
f: '3d:productad',
src: ''
},
{
t: 'Kurukshetra \u2014 AI film glimpse',
c: 'AI',
f: '3d:archer',
src: ''
},
{
t: 'Panda\u2019s Bamboo Day \u2014 3D short',
c: '3D',
f: '3d:bamboo',
src: ''
},
{
t: 'Health insurance \u2014 whiteboard explainer',
c: 'Whiteboard',
f: '2d:wb2',
src: ''
},
{
t: 'Goal! \u2014 2D character animation',
c: '2D',
f: '2d:park',
src: ''
},
{
t: 'Dance Party \u2014 3D kids music video',
c: 'Kids',
f: '3d:dance',
src: ''
},
{
t: 'Solar savings \u2014 whiteboard explainer',
c: 'Whiteboard',
f: '2d:wb3',
src: ''
},
{
t: 'Robo & the Tiny Moon \u2014 3D short',
c: '3D',
f: '3d:robomoon',
src: ''
},
{
t: 'Kinetic typography \u2014 brand ad',
c: 'Ads',
f: '2d:kinetic',
src: ''
},
{
t: 'Logo sting \u2014 Dutta Innovations',
c: '2D',
f: '2d:logo',
src: ''
},
{
t: 'E-learning promo \u2014 whiteboard explainer',
c: 'Whiteboard',
f: '2d:wb4',
src: ''
},
{
t: 'Hindi & English voiceover reel',
c: 'Voiceover',
f: '2d:vo',
src: '',
audio: ''
}
];
(function() {
var items = CONFIG.portfolio,
grid = $('#pfGrid'),
tabs = $('#pfTabs');
var label = {
AI: 'AI Films',
Kids: 'Kids & Rhymes'
};
var desc = {
'2D': 'Hand-crafted 2D character animation and motion design.',
'3D': '3D characters and worlds \u2014 modelled, rigged, lit and animated in-house.',
'Whiteboard': 'Hand-drawn whiteboard storytelling that makes ideas stick.',
'AI': 'Cinematic AI films \u2014 directed, edited and sound-designed by our team.',
'Ads': 'Short, punchy ad films built for Reels, YouTube and TV.',
'Kids': 'Colourful kids content, nursery rhymes and music videos.',
'Voiceover': 'Voiceovers and character voices in Hindi, English and more.'
};
var svc = {
'2D': '2D Animation',
'3D': '3D Animation',
'Whiteboard': 'Whiteboard Animation',
'AI': 'AI Movie / AI Film',
'Ads': 'Commercial Ad',
'Kids': 'Rhymes / Kids Content',
'Voiceover': 'Voiceover'
};
function isVid(s) {
return /\.(mp4|webm|mov)(\?|$)/i.test(s)
}
function media(it, big) {
if (it.src)
return isVid(it.src) ? '' : '
';
var k = it.f.split(':');
if (k[0] === '3d')
return '
';
return '
';
}
var cats = ['All', '3D', 'AI', 'Whiteboard', '2D', 'Ads', 'Kids', 'Voiceover'];
tabs.innerHTML = cats.map(function(c, i) {
var n = c === 'All' ? items.length : items.filter(function(x) {
return x.c === c
}).length;
return n ? '
' : ''
}).join('');
grid.innerHTML = items.map(function(it, i) {
return '
' + media(it) + '
' +
'
' + (label[it.c] || it.c) + '' + it.t + '
0:' + (it.f === '2d:logo' ? '08' : '10') + '\u25b6
'
}).join('');
var tiles = $$('.tile', grid);
$$('.film2d', grid).forEach(function(el) {
mount2D(el, el.dataset.kind);
});
tabs.addEventListener('click', function(e) {
var b = e.target.closest('button');
if (!b)
return;
var c = b.dataset.cat;
$$('button', tabs).forEach(function(x) {
x.setAttribute('aria-selected', x === b)
});
var n = 0;
tiles.forEach(function(t) {
var show = c === 'All' || t.dataset.cat === c;
t.classList.toggle('hide', !show);
t.classList.remove('pop');
if (show) {
void t.offsetWidth;
t.style.animationDelay = (n++ * 45) + 'ms';
t.classList.add('pop')
}
});
});
/* player */
var lb = $('#lb'),
stage = $('#lbStage'),
cur = 0,
list = [],
slotEl = null,
film2 = null,
aud = null,
muteBtn = $('#lbMute');
function setMuteUI() {
var m = SFX.isMuted();
muteBtn.textContent = m ? '\ud83d\udd07 Sound off' : '\ud83d\udd0a Sound on';
muteBtn.setAttribute('aria-pressed', !m);
var v = stage.querySelector('video');
if (v)
v.muted = m;
if (aud)
aud.muted = m;
}
function clear() {
if (slotEl && window.DI_removeSlot)
window.DI_removeSlot(slotEl);
slotEl = null;
if (film2)
unmount2D(film2);
film2 = null;
if (aud) {
aud.pause();
aud = null;
}
stage.innerHTML = '';
}
function show(i) {
cur = (i + list.length) % list.length;
var it = items[+list[cur].dataset.i];
clear();
SFX.setActive(false);
SFX.setActive(true);
stage.innerHTML = media(it, true);
slotEl = stage.querySelector('.char-slot');
if (slotEl && window.DI_addSlot)
window.DI_addSlot(slotEl);
var f2 = stage.querySelector('.film2d');
if (f2)
film2 = mount2D(f2, f2.dataset.kind, {
sound: true
});
if (it.audio) {
aud = new Audio(it.audio);
aud.loop = true;
aud.play().catch(function() {});
}
$('#lbCat').textContent = label[it.c] || it.c;
$('#lbTitle').textContent = it.t;
$('#lbDesc').textContent = desc[it.c] || '';
$('#lbWa').href = waLink('Hi Dutta Innovations! I saw "' + it.t + '" in your portfolio. I want something in this style for my project.');
$('#lbQuote').onclick = function() {
close();
if (window.DI_pick)
window.DI_pick(svc[it.c])
};
setMuteUI();
}
function open(t) {
list = tiles.filter(function(x) {
return !x.classList.contains('hide')
});
lb.classList.add('open');
lb.setAttribute('aria-hidden', 'false');
ROOT.classList.add('lb-open');
SFX.setActive(true);
show(list.indexOf(t));
$('.lb-x').focus();
}
function close() {
lb.classList.remove('open');
lb.setAttribute('aria-hidden', 'true');
ROOT.classList.remove('lb-open');
SFX.setActive(false);
clear();
}
grid.addEventListener('click', function(e) {
var t = e.target.closest('.tile');
if (t)
open(t)
});
grid.addEventListener('keydown', function(e) {
var t = e.target.closest('.tile');
if (t && (e.key === 'Enter' || e.key === ' ')) {
e.preventDefault();
open(t)
}
});
$$('[data-close]', lb).forEach(function(b) {
b.addEventListener('click', close)
});
$('#lbPrev').addEventListener('click', function() {
show(cur - 1)
});
$('#lbNext').addEventListener('click', function() {
show(cur + 1)
});
muteBtn.addEventListener('click', function() {
SFX.setMuted(!SFX.isMuted());
setMuteUI();
});
addEventListener('keydown', function(e) {
if (!lb.classList.contains('open'))
return;
if (e.key === 'Escape')
close();
if (e.key === 'ArrowLeft')
show(cur - 1);
if (e.key === 'ArrowRight')
show(cur + 1)
});
})();
/* ===== brief form ===== */
(function() {
var f = $('#briefForm'),
prev = $('#msgPreview'),
time = $('#msgTime'),
typing = $('#typing'),
tt;
function picked(id) {
return $$('#' + id + ' button[aria-pressed="true"]').map(function(b) {
return b.textContent
})
}
$$('.pick').forEach(function(g) {
g.addEventListener('click', function(e) {
var b = e.target.closest('button');
if (!b)
return;
if (g.hasAttribute('data-multi')) {
b.setAttribute('aria-pressed', b.getAttribute('aria-pressed') !== 'true')
}
else {
$$('button', g).forEach(function(x) {
x.setAttribute('aria-pressed', x === b && x.getAttribute('aria-pressed') !== 'true')
})
}
update()
});
});
function build() {
var d = new FormData(f),
s = picked('pickServices'),
l = picked('pickLen'),
lines = ['Hi Dutta Innovations! \ud83d\udc4b', 'I\u2019d like to discuss an animation project.', ''];
lines.push('\ud83c\udfac Services: ' + (s.length ? s.join(', ') : '\u2014'));
lines.push('\u23f1 Duration: ' + (l[0] || '\u2014'));
if (d.get('deadline'))
lines.push('\ud83d\udcc5 Timeline: ' + d.get('deadline'));
if (d.get('budget'))
lines.push('\ud83d\udcb0 Budget: ' + d.get('budget'));
lines.push('');
lines.push('\ud83d\udc64 Name: ' + (d.get('name') || '\u2014'));
lines.push('\ud83d\udcde Phone: ' + (d.get('phone') || '\u2014'));
if (d.get('email'))
lines.push('\u2709 Email: ' + d.get('email'));
if (d.get('company'))
lines.push('\ud83c\udfe2 Company: ' + d.get('company'));
if (d.get('msg'))
lines.push('', '\ud83d\udcdd Idea: ' + d.get('msg'));
lines.push('', '(Sent from the Animation page)');
return lines.join('\n');
}
function update() {
prev.textContent = build();
var n = new Date();
time.textContent = n.getHours() + ':' + String(n.getMinutes()).padStart(2, '0') + ' \u2713\u2713';
typing.style.visibility = 'visible';
clearTimeout(tt);
tt = setTimeout(function() {
typing.style.visibility = 'hidden'
}, 900);
}
f.addEventListener('input', update);
update();
/* "Get a quote" buttons on cards pre-select the service */
window.DI_pick = function(v) {
$$('#pickServices button').forEach(function(b) {
if (b.textContent === v)
b.setAttribute('aria-pressed', 'true')
});
update();
$('#contact').scrollIntoView({
behavior: 'smooth'
})
};
$$('[data-pick]').forEach(function(a) {
a.addEventListener('click', function() {
var v = a.dataset.pick;
$$('#pickServices button').forEach(function(b) {
if (b.textContent === v)
b.setAttribute('aria-pressed', 'true')
});
update()
})
});
function valid() {
var ok = true,
n = f.name.value.trim(),
p = f.phone.value.replace(/\D/g, '');
$('#fName').classList.toggle('err', !n);
$('#fPhone').classList.toggle('err', p.length < 10);
if (!n || p.length < 10) {
ok = false;
toast('Please add your name and a valid phone number \ud83d\ude4f');
(n ? f.phone : f.name).focus()
}
return ok;
}
function backup() {
if (!CONFIG.formspree)
return;
try {
fetch(CONFIG.formspree, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: build(),
name: f.name.value,
phone: f.phone.value,
email: f.email.value,
_subject: 'New animation enquiry'
})
})
} catch (e) {}
}
f.addEventListener('submit', function(e) {
e.preventDefault();
if (!valid())
return;
backup();
window.open(waLink(build()), '_blank', 'noopener');
toast('Opening WhatsApp \u2014 just press Send \u2726');
confetti()
});
$('#emailBtn').addEventListener('click', function() {
if (!valid())
return;
backup();
location.href = 'mailto:' + CONFIG.email + '?subject=' + encodeURIComponent('Animation project enquiry \u2014 ' + f.name.value) + '&body=' + encodeURIComponent(build());
toast('Opening your email app \u2709')
});
})();
var toastEl = $('#toast'),
toastT;
function toast(m) {
toastEl.textContent = m;
toastEl.classList.add('show');
clearTimeout(toastT);
toastT = setTimeout(function() {
toastEl.classList.remove('show')
}, 3200)
}
function confetti() {
if (reduce)
return;
var co = ['#FF5A5F', '#FFC23C', '#2EC4B6', '#7B5CFF', '#4CC9F0', '#FF8FB1'];
for (var i = 0; i < 60; i++) {
(function() {
var s = document.createElement('i');
s.style.cssText = 'position:fixed;z-index:3000;top:-10px;left:' + Math.random() * 100 + 'vw;width:9px;height:14px;border-radius:2px;pointer-events:none;background:' + co[(Math.random() * 6) | 0];
ROOT.appendChild(s);
var x = (Math.random() - .5) * 200,
r = Math.random() * 720;
s.animate([{
transform: 'translate(0,0) rotate(0)'
}, {
transform: 'translate(' + x + 'px,' + (innerHeight + 40) + 'px) rotate(' + r + 'deg)'
}], {
duration: 1600 + Math.random() * 1400,
easing: 'cubic-bezier(.2,.6,.4,1)'
}).onfinish = function() {
s.remove()
}
})()
}
}
window.DI_toast = toast;
onScroll();
})();
import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js';
const ROOT = document.getElementById('dia') || document.body;
/* soft studio environment (replaces RoomEnvironment so no import map is needed) */
function studioScene() {
const s = new THREE.Scene();
const room = new THREE.Mesh(new THREE.BoxGeometry(12, 7, 12), new THREE.MeshBasicMaterial({
color: 0x6e6a7c,
side: THREE.BackSide
}));
room.position.y = 2.5;
s.add(room);
const L = (c, i, p, w, h) => {
const m = new THREE.Mesh(new THREE.PlaneGeometry(w, h), new THREE.MeshBasicMaterial({
color: new THREE.Color(c).multiplyScalar(i),
side: THREE.DoubleSide
}));
m.position.set(...p);
m.lookAt(0, 1.5, 0);
s.add(m);
};
L('#ffffff', 5, [0, 5.8, 0], 5, 5);
L('#ffe6cc', 4, [-5.8, 3, 1], 3, 2.5);
L('#d6e4ff', 4, [5.8, 3, -1], 3, 2.5);
L('#ffffff', 2.5, [0, 2.5, 5.8], 5, 2.5);
L('#ffd6ec', 2, [0, 2, -5.8], 4, 2);
return s;
}
const rbCache = new Map();
function RoundedBoxGeometry(w, h, d, seg, r) {
const key = [w, h, d, r].join();
if (rbCache.has(key))
return rbCache.get(key);
r = Math.max(0.002, Math.min(r, w / 2 * 0.98, h / 2 * 0.98, d / 2 * 0.98));
const iw = w - 2 * r,
ih = h - 2 * r,
cr = Math.min(iw, ih) * 0.25,
s = new THREE.Shape(),
x = -iw / 2,
y = -ih / 2;
s.moveTo(x + cr, y);
s.lineTo(x + iw - cr, y);
s.quadraticCurveTo(x + iw, y, x + iw, y + cr);
s.lineTo(x + iw, y + ih - cr);
s.quadraticCurveTo(x + iw, y + ih, x + iw - cr, y + ih);
s.lineTo(x + cr, y + ih);
s.quadraticCurveTo(x, y + ih, x, y + ih - cr);
s.lineTo(x, y + cr);
s.quadraticCurveTo(x, y, x + cr, y);
const g = new THREE.ExtrudeGeometry(s, {
depth: Math.max(0.001, d - 2 * r),
bevelEnabled: true,
bevelThickness: r,
bevelSize: r,
bevelSegments: 4,
curveSegments: 6
});
g.center();
g.computeVertexNormals();
rbCache.set(key, g);
return g;
}
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
const lerp = (a, b, t) => a + (b - a) * t,
clamp = (v, a, b) => Math.max(a, Math.min(b, v));
const seg = (t, a, b) => clamp((t - a) / (b - a), 0, 1),
ease = x => x a + Math.random() * (b - a),
pick = a => a[(Math.random() * a.length) | 0];
function webglOK() {
try {
const c = document.createElement('canvas');
return !!(c.getContext('webgl2') || c.getContext('webgl'))
} catch (e) {
return false
}
}
if (!webglOK()) {
document.getElementById('heroStage').classList.add('no-webgl');
}
const SFX = () => window.SFX;
function O(obj, props) {
if (props)
for (const k in props) {
const v = props[k];
if (k === 'position' || k === 'scale' || k === 'rotation')
obj[k].copy(v);
else
obj[k] = v;
}
return obj;
}
/* ================= look: soft "designer-toy" PBR ================= */
const SPH = new THREE.SphereGeometry(1, 40, 28);
const envCache = new WeakMap();
function envFor(r) {
if (!envCache.has(r)) {
const pm = new THREE.PMREMGenerator(r);
envCache.set(r, pm.fromScene(studioScene(), 0.04).texture);
pm.dispose();
}
return envCache.get(r);
}
function setup(r) {
r.toneMapping = THREE.ACESFilmicToneMapping;
r.toneMappingExposure = 1.05;
r.outputColorSpace = THREE.SRGBColorSpace;
}
const mats = new Map();
function M(color, kind='toy') {
const key = color + '|' + kind;
if (mats.has(key))
return mats.get(key);
const c = new THREE.Color(color),
W = new THREE.Color('#ffffff');
let m;
switch (kind) {
case 'fabric':
m = new THREE.MeshPhysicalMaterial({
color: c,
roughness: .8,
sheen: 1,
sheenRoughness: .45,
sheenColor: c.clone().lerp(W, .55)
});
break;
case 'skin':
m = new THREE.MeshPhysicalMaterial({
color: c,
roughness: .48,
clearcoat: .35,
clearcoatRoughness: .45,
sheen: .5,
sheenColor: new THREE.Color('#ffd9c9')
});
break;
case 'gloss':
m = new THREE.MeshPhysicalMaterial({
color: c,
roughness: .05,
clearcoat: 1,
clearcoatRoughness: .03
});
break;
case 'hair':
m = new THREE.MeshPhysicalMaterial({
color: c,
roughness: .4,
clearcoat: .55,
clearcoatRoughness: .3,
side: THREE.DoubleSide
});
break;
case 'metal':
m = new THREE.MeshPhysicalMaterial({
color: c,
roughness: .28,
metalness: .85
});
break;
case 'matte':
m = new THREE.MeshStandardMaterial({
color: c,
roughness: .95
});
break;
case 'flat':
m = new THREE.MeshStandardMaterial({
color: c,
roughness: .95,
flatShading: true
});
break;
case 'glow':
m = new THREE.MeshBasicMaterial({
color: c
});
break;
case 'lid':
m = new THREE.MeshPhysicalMaterial({
color: c,
roughness: .45,
clearcoat: .3,
clearcoatRoughness: .4,
sheen: .5,
sheenColor: new THREE.Color('#ffd9c9'),
side: THREE.DoubleSide
});
break;
case 'emis':
m = new THREE.MeshStandardMaterial({
color: c,
emissive: c,
emissiveIntensity: 1.4,
roughness: .4
});
break;
default:
m = new THREE.MeshPhysicalMaterial({
color: c,
roughness: .33,
clearcoat: .75,
clearcoatRoughness: .18
});
}
mats.set(key, m);
return m;
}
const RB = (w, h, d, r=.08) => new RoundedBoxGeometry(w, h, d, 4, r);
function mk(geo, color, kind, p, parent, s) {
const m = new THREE.Mesh(geo, M(color, kind));
m.position.set(...p);
if (s)
m.scale.set(...s);
m.castShadow = true;
m.receiveShadow = true;
parent.add(m);
return m;
}
function canvasTex(w, h, draw) {
const c = document.createElement('canvas');
c.width = w;
c.height = h;
draw(c.getContext('2d'), w, h);
const t = new THREE.CanvasTexture(c);
t.colorSpace = THREE.SRGBColorSpace;
t.anisotropy = 4;
return t;
}
const glowTex = canvasTex(128, 128, (x) => {
const g = x.createRadialGradient(64, 64, 0, 64, 64, 64);
g.addColorStop(0, 'rgba(255,255,255,1)');
g.addColorStop(.25, 'rgba(255,255,255,.55)');
g.addColorStop(1, 'rgba(255,255,255,0)');
x.fillStyle = g;
x.fillRect(0, 0, 128, 128);
});
function glow(color, size, op=1) {
const s = new THREE.Sprite(new THREE.SpriteMaterial({
map: glowTex,
color,
transparent: true,
opacity: op,
blending: THREE.AdditiveBlending,
depthWrite: false,
fog: false
}));
s.scale.set(size, size, 1);
return s;
}
function shadowRes() {
const t = canvasTex(64, 64, (x) => {
const g = x.createRadialGradient(32, 32, 0, 32, 32, 32);
g.addColorStop(0, 'rgba(30,15,70,.34)');
g.addColorStop(1, 'rgba(30,15,70,0)');
x.fillStyle = g;
x.fillRect(0, 0, 64, 64);
});
return {
mat: new THREE.MeshBasicMaterial({
map: t,
transparent: true,
depthWrite: false
}),
geo: new THREE.PlaneGeometry(1.4, 1.4)
};
}
function blob(scene, res, x, z, s=1, y=0.01) {
const m = new THREE.Mesh(res.geo, res.mat);
m.rotation.x = -Math.PI / 2;
m.position.set(x, y, z);
m.scale.setScalar(s);
scene.add(m);
return m;
}
function skyDome(stops, r=80) {
const t = canvasTex(4, 512, (x, w, h) => {
const g = x.createLinearGradient(0, 0, 0, h);
stops.forEach(([o, c]) => g.addColorStop(o, c));
x.fillStyle = g;
x.fillRect(0, 0, w, h);
});
return new THREE.Mesh(new THREE.SphereGeometry(r, 32, 24), new THREE.MeshBasicMaterial({
map: t,
side: THREE.BackSide,
fog: false,
depthWrite: false
}));
}
function points(n, box, color, size, add=true) {
const g = new THREE.BufferGeometry(),
p = new Float32Array(n * 3);
for (let i = 0; i < n; i++) {
p[i * 3] = rnd(box[0], box[1]);
p[i * 3 + 1] = rnd(box[2], box[3]);
p[i * 3 + 2] = rnd(box[4], box[5]);
}
g.setAttribute('position', new THREE.BufferAttribute(p, 3));
return new THREE.Points(g, new THREE.PointsMaterial({
color,
size,
map: glowTex,
transparent: true,
depthWrite: false,
blending: add ? THREE.AdditiveBlending : THREE.NormalBlending,
sizeAttenuation: true
}));
}
function lights(scene, o={}) {
scene.add(new THREE.HemisphereLight(o.sky || 0xffffff, o.ground || 0xd9ccff, o.hemi ?? 1.0));
const k = new THREE.DirectionalLight(o.key || 0xffffff, o.keyI ?? 2.4);
k.position.set(...(o.keyP || [3, 6, 5]));
scene.add(k);
const r = new THREE.DirectionalLight(o.rim || 0xcfe0ff, o.rimI ?? 1.6);
r.position.set(...(o.rimP || [-4, 4, -5]));
scene.add(r);
return {
k,
r
};
}
/* ================= characters ================= */
function buildChar(o) {
if (o.toon)
return buildToon(o);
const meshes = [],
pickables = [],
outlines = [];
const root = new THREE.Group(),
rig = new THREE.Group();
root.add(rig);
function add(parent, geo, color, p=[0, 0, 0], s=[1, 1, 1], kind='toy') {
const m = new THREE.Mesh(geo, M(color, kind));
m.position.set(...p);
m.scale.set(...s);
m.castShadow = true;
parent.add(m);
meshes.push(m);
pickables.push(m);
return m;
}
const isCat = o.type === 'cat',
isBot = o.type === 'robot',
isPanda = o.type === 'panda',
furry = isCat || isPanda;
const cloth = isBot ? 'toy' : 'fabric',
skinK = isBot ? 'toy' : furry ? 'fabric' : 'skin';
const legGeo = new THREE.CapsuleGeometry(0.13, 0.3, 6, 16),
legs = [];
for (const sx of [-1, 1]) {
const lp = new THREE.Group();
lp.position.set(sx * 0.17, 0.56, 0);
rig.add(lp);
add(lp, legGeo, o.pants, [0, -0.2, 0], [1, 1, 1], cloth);
add(lp, SPH, o.shoe || '#FFFFFF', [0, -0.46, 0.06], [0.17, 0.11, 0.23], 'toy');
legs.push(lp);
}
const body = add(rig, new THREE.CapsuleGeometry(0.4, 0.42, 12, 28), o.shirt, [0, 0.98, 0], [1, 1, 0.9], cloth);
if (isBot) {
add(rig, SPH, '#7CF0FF', [0, 1.05, 0.36], [0.12, 0.12, 0.04], 'emis');
}
else
add(rig, SPH, o.badge || '#FFFFFF', [0.15, 1.12, 0.355], [0.075, 0.075, 0.03], 'toy');
if (isCat) {
const tail = add(rig, new THREE.TorusGeometry(0.32, 0.07, 12, 28, Math.PI * 1.25), o.shirt, [0, 0.75, -0.42], [1, 1, 1], 'fabric');
tail.rotation.y = Math.PI / 2;
tail.rotation.z = -0.4;
}
const arms = [];
for (const sx of [-1, 1]) {
const pv = new THREE.Group();
pv.position.set(sx * 0.4, 1.22, 0);
rig.add(pv);
add(pv, new THREE.CapsuleGeometry(0.1, 0.32, 6, 14), o.sleeve || o.shirt, [0, -0.26, 0], [1, 1, 1], cloth);
const hand = add(pv, SPH, isBot ? '#D7DFEF' : (o.hand || o.skin), [0, -0.52, 0], [0.13, 0.13, 0.13], isBot ? 'metal' : (o.hand ? 'fabric' : skinK));
pv.rotation.z = sx * 0.22;
pv.userData.sx = sx;
pv.userData.hand = hand;
arms.push(pv);
}
const head = new THREE.Group();
head.position.set(0, 1.45, 0);
rig.add(head);
const R = 0.64;
add(head, SPH, o.skin, [0, 0.5, 0], [R, R * 0.96, R * 0.98], skinK);
const eyes = [],
pupils = [];
let mouth;
if (isBot) {
const vis = add(head, new THREE.CapsuleGeometry(0.17, 0.5, 6, 20), '#1B1340', [0, 0.55, 0.48], [1, 1, 0.6], 'gloss');
vis.rotation.z = Math.PI / 2;
for (const sx of [-1, 1]) {
const e = add(head, SPH, '#7CF0FF', [sx * 0.2, 0.56, 0.6], [0.085, 0.085, 0.05], 'emis');
e.userData.sy = 0.085;
eyes.push(e);
}
mouth = add(head, new THREE.TorusGeometry(0.08, 0.022, 8, 20, Math.PI), '#7CF0FF', [0, 0.3, 0.6], [1, 1, 1], 'emis');
mouth.rotation.z = Math.PI;
for (const sx of [-1, 1])
add(head, new THREE.CylinderGeometry(0.12, 0.12, 0.12, 24), '#FF5A5F', [sx * 0.64, 0.5, 0], [1, 1, 1], 'toy').rotation.z = Math.PI / 2;
add(head, new THREE.CylinderGeometry(0.025, 0.025, 0.3, 8), '#9AA7C7', [0, 1.24, 0], [1, 1, 1], 'metal');
add(head, SPH, '#FF5A5F', [0, 1.42, 0], [0.08, 0.08, 0.08], 'emis');
} else {
for (const sx of [-1, 1]) {
const eg = new THREE.Group();
eg.position.set(sx * 0.23, 0.55, 0.49);
head.add(eg);
add(eg, SPH, '#FFFFFF', [0, 0, 0], [0.158, 0.19, 0.11], 'gloss');
const look = new THREE.Group();
look.position.z = 0.07;
eg.add(look);
add(look, SPH, o.eye || (isCat ? '#3FA34D' : '#4A2C1E'), [0, 0, 0], [0.105, 0.125, 0.05], 'gloss');
add(look, SPH, '#0E0A1A', [0, 0, 0.03], [0.06, 0.072, 0.03], 'gloss');
add(look, SPH, '#FFFFFF', [0.035, 0.05, 0.06], [0.032, 0.032, 0.02], 'glow');
add(look, SPH, '#FFFFFF', [-0.03, -0.045, 0.055], [0.015, 0.015, 0.01], 'glow');
eyes.push(eg);
pupils.push(look);
if (!furry) {
const br = add(head, new THREE.CapsuleGeometry(0.022, 0.1, 4, 8), o.hair || '#2B1B17', [sx * 0.23, 0.8, 0.5], [1, 1, 1], 'toy');
br.rotation.z = Math.PI / 2 + sx * 0.18;
}
}
for (const sx of [-1, 1])
add(head, SPH, '#FF8FAB', [sx * 0.37, 0.35, 0.5], [0.09, 0.06, 0.03], 'skin');
mouth = add(head, new THREE.TorusGeometry(0.085, 0.024, 10, 24, Math.PI), '#5A1A2B', [0, 0.32, 0.6], [1, 1, 1], 'toy');
mouth.rotation.z = Math.PI;
if (isCat) {
add(head, SPH, '#FF7A9A', [0, 0.42, 0.62], [0.055, 0.04, 0.04], 'gloss');
for (const sx of [-1, 1]) {
const ear = add(head, new THREE.ConeGeometry(0.2, 0.34, 16), o.skin, [sx * 0.36, 1.02, 0], [1, 1, 0.6], 'fabric');
ear.rotation.z = -sx * 0.38;
const inr = add(head, new THREE.ConeGeometry(0.12, 0.22, 16), '#FFB3C6', [sx * 0.355, 1.0, 0.05], [1, 1, 0.4], 'skin');
inr.rotation.z = -sx * 0.38;
for (const dy of [0.02, -0.06]) {
const w = add(head, new THREE.CylinderGeometry(0.006, 0.006, 0.3, 4), '#3A2A20', [sx * 0.43, 0.38 + dy, 0.5], [1, 1, 1], 'toy');
w.rotation.z = Math.PI / 2 + sx * dy * 3;
}
}
} else if (isPanda) {
for (const sx of [-1, 1]) {
add(head, SPH, '#24212E', [sx * 0.44, 1.0, -0.06], [0.21, 0.21, 0.15], 'fabric');
const pt = add(head, SPH, '#24212E', [sx * 0.23, 0.53, 0.45], [0.18, 0.23, 0.1], 'fabric');
pt.rotation.z = sx * 0.55;
}
add(head, SPH, '#24212E', [0, 0.41, 0.62], [0.075, 0.055, 0.05], 'gloss');
hair(Object.assign({}, o, {
hairStyle: 'none'
}));
} else {
for (const sx of [-1, 1])
add(head, SPH, o.skin, [sx * 0.62, 0.5, 0], [0.12, 0.14, 0.09], 'skin');
hair(o);
}
}
function hair(o) {
const hc = o.hair,
top = [0, 0.5, 0];
if (o.hairStyle !== 'beanie' && o.hairStyle !== 'none') {
const cap = add(head, new THREE.SphereGeometry(1, 40, 20, 0, Math.PI * 2, 0, Math.PI * 0.43), hc, top, [0.665, 0.665, 0.665], 'hair');
cap.rotation.x = -0.32;
for (let i = 0; i < 5; i++) {
const b = add(head, SPH, hc, [-0.32 + i * 0.16, 0.9 - Math.abs(i - 2) * 0.02, 0.42 - Math.abs(i - 2) * 0.04], [0.13, 0.1, 0.1], 'hair');
b.rotation.z = (i - 2) * 0.3;
}
}
if (o.hairStyle === 'buns')
for (const sx of [-1, 1])
add(head, SPH, hc, [sx * 0.42, 1.02, -0.08], [0.22, 0.22, 0.22], 'hair');
if (o.hairStyle === 'pony') {
add(head, SPH, hc, [0, 0.68, -0.62], [0.21, 0.23, 0.21], 'hair');
add(head, SPH, hc, [0, 0.36, -0.74], [0.16, 0.24, 0.16], 'hair');
}
if (o.hairStyle === 'spiky') {
for (let i = 0; i < 6; i++) {
const a = -0.9 + i * 0.36;
const c = add(head, new THREE.ConeGeometry(0.13, 0.32, 12), hc, [Math.sin(a) * 0.45, 1.06, -0.17 + Math.cos(a) * 0.08], [1, 1, 1], 'hair');
c.rotation.z = -Math.sin(a) * 0.8;
c.rotation.x = -0.3;
}
}
if (o.hairStyle === 'curly') {
for (let i = 0; i performance.now() / 1000;
function setExpr(c, name, dur=2.2) {
if (!c || !c.face)
return;
c.face.tgt = Object.assign({}, EXPR.neutral, EXPR[name] || {});
c.face.until = nowS() + dur;
c.face.name = name;
}
function updateFace(c, dt, yaw=0, pitch=0) {
const f = c.face;
if (!f)
return;
const now = nowS();
if (f.until && now > f.until) {
f.until = 0;
f.tgt = Object.assign({}, EXPR.neutral, EXPR[c.idleExpr || 'neutral'] || {});
f.name = c.idleExpr || 'neutral';
}
const k = Math.min(1, dt * 11),
cur = f.cur,
g = f.tgt;
for (const key in EXPR.neutral)
cur[key] = lerp(cur[key], g[key] ?? EXPR.neutral[key], k);
if (now > f.nextBlink) {
f.blinkUntil = now + 0.13;
f.nextBlink = now + 2 + Math.random() * 3.5;
}
const bl = now {
const v = bl ? 1.05 : (i ? cur.lidR : cur.lidL);
l.rotation.x = lerp(-1.7, 1.5, clamp(v, -.1, 1.08));
});
f.looks.forEach(l => {
l.rotation.y = clamp(yaw * 0.55 + cur.lookX, -0.55, 0.55);
l.rotation.x = clamp(pitch * 0.5 + cur.lookY, -0.45, 0.45);
});
f.brows.forEach((b, i) => {
const sx = i ? 1 : -1,
r = i ? cur.browR : cur.browL;
b.position.y = b.userData.y0 + r * 0.075;
b.rotation.z = sx * cur.browTilt * 0.42;
});
let open = cur.open;
if (c.talkUntil && now 0.05;
m.cav.scale.set(0.15 * w, h, 0.04);
m.teeth.visible = open > 0.22;
m.teeth.position.y = h * 0.55;
m.teeth.scale.set(1, w * 0.9, 1);
m.tongue.visible = open > 0.4;
m.tongue.position.y = -h * 0.45;
m.tongue.scale.set(0.085 * w, 0.04, 0.03);
m.line.visible = open = 0 ? Math.PI : 0;
m.line.position.y = cur.smile >= 0 ? 0.03 : -0.045;
const sa = Math.abs(cur.smile);
m.line.scale.set(w * (0.6 + 0.4 * sa), 0.45 + 0.75 * sa, 1);
const bs = 0.55 + cur.blush * 0.55;
f.blush.forEach(b => b.scale.set(0.085 * bs, 0.052 * bs, 0.03));
f.cheeks.forEach(ch => ch.position.y = ch.userData.y0 + Math.max(0, cur.smile) * open * 0.035);
}
function buildToon(o) {
const meshes = [],
pickables = [];
const root = new THREE.Group(),
rig = new THREE.Group();
root.add(rig);
function add(parent, geo, color, p=[0, 0, 0], s=1, kind='toy') {
const m = new THREE.Mesh(geo, M(color, kind));
m.position.set(...p);
if (typeof s === 'number')
m.scale.setScalar(s);
else
m.scale.set(...s);
m.castShadow = true;
parent.add(m);
meshes.push(m);
pickables.push(m);
return m;
}
const panda = o.type === 'panda',
skinK = panda ? 'fabric' : 'skin',
HC = o.hair || '#1E1412',
of = o.outfit;
const legGeo = new THREE.CapsuleGeometry(0.13, 0.3, 6, 16),
legs = [];
for (const sx of [-1, 1]) {
const lp = new THREE.Group();
lp.position.set(sx * 0.17, 0.56, 0);
rig.add(lp);
add(lp, legGeo, o.pants, [0, -0.2, 0], 1, 'fabric');
add(lp, SPH, o.shoe || '#FFFFFF', [0, -0.46, 0.06], [0.17, 0.11, 0.23], 'toy');
legs.push(lp);
}
const body = add(rig, new THREE.CapsuleGeometry(0.4, 0.42, 12, 28), of === 'jacket' ? o.jacket : o.top, [0, 0.98, 0], [1, 1, 0.9], 'fabric');
if (of === 'jacket' || of === 'kurta') {
if (of === 'jacket')
add(rig, RB(0.17, 0.66, 0.06, 0.03), o.top, [0, 0.98, 0.345], 1, 'fabric');
for (let i = 0; i {
const cv = new THREE.CatmullRomCurve3([[-0.37 * sx, 1.32, 0.0], [-0.14 * sx, 1.2, 0.36], [0.18 * sx, 0.96, 0.38], [0.39 * sx, 0.7, 0.18]].map(p => new THREE.Vector3(...p)));
add(rig, new THREE.TubeGeometry(cv, 28, 0.085, 12), o.drape, [0, 0, 0], 1, 'fabric');
add(rig, new THREE.TubeGeometry(cv, 28, 0.092, 12, false), '#E8C15A', [0, -0.05, 0.0], [1, 1, 1], 'metal').scale.set(1, 0.98, 1);
};
mk2(1);
if (of === 'shawl')
mk2(-1);
}
if (of === 'apron') {
add(rig, SPH, o.apron || '#FFFFFF', [0, 0.86, 0.29], [0.3, 0.36, 0.1], 'fabric');
const ring = add(rig, new THREE.TorusGeometry(0.405, 0.02, 8, 40), o.apron || '#FFFFFF', [0, 0.82, 0], [1, 0.9, 1], 'fabric');
ring.rotation.x = Math.PI / 2;
ring.scale.set(1, 0.9, 1);
}
if (of === 'hoodie') {
const hood = add(rig, new THREE.TorusGeometry(0.26, 0.1, 10, 24), o.top, [0, 1.36, -0.2], 1, 'fabric');
hood.rotation.x = 1.15;
for (const sx of [-1, 1])
add(rig, new THREE.CylinderGeometry(0.013, 0.013, 0.24, 6), '#FFFFFF', [sx * 0.08, 1.18, 0.355], 1, 'toy');
add(rig, RB(0.38, 0.15, 0.06, 0.03), o.top2 || '#2FA8CF', [0, 0.82, 0.33], 1, 'fabric');
}
if (of === 'frock') {
add(rig, new THREE.CylinderGeometry(0.36, 0.52, 0.36, 36), o.top, [0, 0.66, 0], 1, 'fabric');
const belt = add(rig, new THREE.TorusGeometry(0.39, 0.035, 8, 36), o.ribbon || '#FFC23C', [0, 0.86, 0], 1, 'toy');
belt.rotation.x = Math.PI / 2;
}
if (of === 'tee') {
add(rig, SPH, '#FFFFFF', [0, 1.06, 0.35], [0.12, 0.12, 0.03], 'toy');
add(rig, SPH, o.badge || '#FF5A5F', [0, 1.06, 0.375], [0.065, 0.065, 0.02], 'toy');
}
const arms = [];
for (const sx of [-1, 1]) {
const pv = new THREE.Group();
pv.position.set(sx * 0.4, 1.22, 0);
rig.add(pv);
add(pv, new THREE.CapsuleGeometry(0.1, 0.32, 6, 14), o.sleeve || (of === 'jacket' ? o.top : o.top), [0, -0.26, 0], 1, 'fabric');
const hand = add(pv, SPH, o.hand || o.skin, [0, -0.52, 0], 0.13, o.hand ? 'fabric' : skinK);
pv.rotation.z = sx * 0.22;
pv.userData.sx = sx;
pv.userData.hand = hand;
arms.push(pv);
}
const head = new THREE.Group();
head.position.set(0, 1.45, 0);
rig.add(head);
const F = new THREE.Group();
F.position.set(0, 0.55, 0);
head.add(F);
add(F, SPH, o.skin, [0, 0, 0], [0.62, 0.64, 0.6], skinK);
const cheeks = [];
for (const sx of [-1, 1]) {
const ch = add(F, SPH, o.skin, [sx * 0.29, -0.22, 0.33], [0.17, 0.15, 0.17], skinK);
ch.userData.y0 = -0.22;
cheeks.push(ch);
}
add(F, SPH, o.skin, [0, -0.33, 0.3], [0.18, 0.13, 0.16], skinK);
if (!panda)
for (const sx of [-1, 1]) {
add(F, SPH, o.skin, [sx * 0.61, -0.02, 0], [0.1, 0.15, 0.08], skinK);
add(F, SPH, shade(o.skin, 0.18), [sx * 0.64, -0.02, 0.02], [0.05, 0.09, 0.04], skinK);
}
if (panda) {
for (const sx of [-1, 1]) {
add(F, SPH, '#24212E', [sx * 0.44, 0.48, -0.06], [0.21, 0.21, 0.15], 'fabric');
const pt = add(F, SPH, '#24212E', [sx * 0.22, 0.06, 0.43], [0.19, 0.24, 0.13], 'fabric');
pt.rotation.z = sx * 0.5;
}
}
add(F, SPH, panda ? '#24212E' : shade(o.skin, 0.12, '#E86A5A'), [0, -0.07, 0.58], panda ? [0.085, 0.065, 0.06] : [0.105, 0.088, 0.1], panda ? 'gloss' : skinK);
const lids = [],
looks = [];
for (const sx of [-1, 1]) {
const eg = new THREE.Group();
eg.position.set(sx * 0.215, 0.08, 0.46);
F.add(eg);
add(eg, SPH, '#FFFFFF', [0, 0, 0], [0.162, 0.178, 0.142], 'gloss');
const look = new THREE.Group();
eg.add(look);
looks.push(look);
add(look, SPH, o.eye || '#5A3520', [0, 0, 0.112], [0.1, 0.11, 0.042], 'gloss');
add(look, SPH, '#0A0606', [0, 0, 0.136], [0.052, 0.06, 0.02], 'gloss');
add(look, SPH, '#FFFFFF', [0.036, 0.046, 0.15], 0.026, 'glow');
add(look, SPH, '#FFFFFF', [-0.03, -0.036, 0.147], 0.013, 'glow');
const lp = new THREE.Group();
eg.add(lp);
const lid = new THREE.Mesh(LIDGEO, M(panda ? '#24212E' : o.skin, 'lid'));
lid.scale.set(0.172, 0.19, 0.153);
lid.castShadow = true;
lp.add(lid);
lids.push(lp);
meshes.push(lid);
pickables.push(lid);
if (o.lashes) {
const ls = add(lp, new THREE.TorusGeometry(0.15, 0.012, 6, 20, Math.PI * 0.7), '#1A1010', [0, 0, 0], 1, 'toy');
ls.rotation.set(Math.PI / 2, 0, Math.PI * 0.15 + (sx > 0 ? 0 : Math.PI * 0.0));
ls.position.set(0, 0.0, 0.0);
ls.scale.set(1.05, 1.05, 1);
ls.rotation.order = 'YXZ';
}
}
const brows = [];
for (const sx of [-1, 1]) {
const b = new THREE.Group();
b.position.set(sx * 0.2, 0.3, 0.5);
b.rotation.y = sx * 0.35;
F.add(b);
const bm = add(b, new THREE.CapsuleGeometry(0.036, 0.15, 6, 12), o.brow || HC, [0, 0, 0], [1, 1, 0.8], 'hair');
bm.rotation.z = Math.PI / 2 - sx * 0.08;
b.userData.y0 = 0.3;
brows.push(b);
if (panda)
b.visible = false;
}
const MG = new THREE.Group();
MG.position.set(0, o.mustache ? -0.3 : -0.27, 0.53);
F.add(MG);
const cav = add(MG, SPH, '#4A0F18', [0, 0, 0], [0.15, 0.05, 0.04], 'toy');
const teeth = add(MG, new THREE.CapsuleGeometry(0.028, 0.17, 6, 12), '#FFFFFF', [0, 0.03, 0.035], 1, 'gloss');
teeth.rotation.z = Math.PI / 2;
const tongue = add(MG, SPH, '#FF6B7A', [0, -0.03, 0.03], [0.085, 0.04, 0.03], 'skin');
const line = add(MG, new THREE.TorusGeometry(0.09, 0.02, 10, 24, Math.PI), panda ? '#24212E' : (o.lip || '#7A2A2E'), [0, 0.03, 0.02], 1, 'toy');
const blush = [];
for (const sx of [-1, 1])
blush.push(add(F, SPH, '#FF7F95', [sx * 0.33, -0.13, 0.5], [0.085, 0.052, 0.03], 'skin'));
/* hair */
const cap = (color, theta=0.43, tilt=-0.32, sc=0.665) => {
const c = add(F, new THREE.SphereGeometry(1, 40, 20, 0, Math.PI * 2, 0, Math.PI * theta), color, [0, 0, 0], sc, 'hair');
c.rotation.x = tilt;
return c;
};
const hs = o.hairStyle;
if (hs === 'side') {
cap(HC);
for (let i = 0; i < 6; i++) {
const b = add(F, SPH, HC, [-0.36 + i * 0.13, 0.42 - i * 0.03, 0.36 - Math.abs(i - 2.5) * 0.03], [0.15, 0.11, 0.11], 'hair');
b.rotation.z = -0.5;
}
add(F, new THREE.ConeGeometry(0.1, 0.25, 12), HC, [0.12, 0.68, 0.05], 1, 'hair').rotation.z = -0.5;
}
if (hs === 'bun') {
cap(HC, 0.45, -0.22);
add(F, SPH, HC, [0, 0.42, -0.46], 0.23, 'hair');
add(F, new THREE.TorusGeometry(0.17, 0.03, 8, 24), '#E8C15A', [0, 0.36, -0.4], 1, 'metal').rotation.x = 0.9;
}
if (hs === 'braids') {
cap(HC);
for (const sx of [-1, 1]) {
for (let i = 0; i add(F, SPH, HC, p, 0.15, 'hair'));
}
if (hs === 'bald') {
for (const sx of [-1, 1])
add(F, SPH, HC, [sx * 0.555, 0.05, -0.12], [0.13, 0.21, 0.3], 'hair');
add(F, SPH, HC, [0, 0, -0.5], [0.44, 0.25, 0.2], 'hair');
}
if (hs === 'short')
cap(HC, 0.4, -0.3);
if (o.topi) {
add(F, new THREE.CylinderGeometry(0.5, 0.565, 0.3, 48), o.topi, [0, 0.49, -0.05], 1, 'fabric').rotation.x = -0.12;
const tp = add(F, SPH, o.topi, [0, 0.645, -0.07], [0.5, 0.1, 0.5], 'fabric');
tp.rotation.x = -0.12;
add(F, new THREE.TorusGeometry(0.555, 0.028, 8, 48), '#E8C15A', [0, 0.37, -0.035], 1, 'metal').rotation.x = Math.PI / 2 - 0.12;
}
if (o.backcap) {
const d = add(F, new THREE.SphereGeometry(1, 40, 20, 0, Math.PI * 2, 0, Math.PI * 0.4), o.backcap, [0, 0.08, -0.02], 0.675, 'toy');
d.rotation.x = -0.42;
const br = add(F, RB(0.46, 0.04, 0.3, 0.02), o.backcap, [0, 0.3, -0.66], 1, 'toy');
br.rotation.x = -0.6;
add(F, SPH, '#FFFFFF', [0, 0.7, -0.2], 0.05, 'toy');
}
if (o.chefHat) {
add(F, new THREE.CylinderGeometry(0.47, 0.43, 0.42, 40), '#FFFFFF', [0, 0.62, -0.03], 1, 'fabric');
[[0, 1.0, 0, .3], [-.27, .92, .05, .25], [.27, .92, .05, .25], [0, .93, -.27, .25], [0, .92, .25, .24]].forEach(([x, y, z, r]) => add(F, SPH, '#FFFFFF', [x, y, z], r, 'fabric'));
}
if (o.headphones) {
add(F, new THREE.TorusGeometry(0.71, 0.05, 10, 32, Math.PI), '#1B1340', [0, 0, 0], 1, 'toy');
for (const sx of [-1, 1])
add(F, new THREE.CylinderGeometry(0.17, 0.17, 0.12, 24), '#FF5A5F', [sx * 0.67, 0, 0], 1, 'toy').rotation.z = Math.PI / 2;
}
if (o.glasses) {
for (const sx of [-1, 1]) {
add(F, new THREE.TorusGeometry(0.16, 0.02, 10, 32), o.glassC || '#3A2A20', [sx * 0.205, 0.08, 0.625], 1, 'gloss');
const arm = add(F, new THREE.CylinderGeometry(0.014, 0.014, 0.5, 6), o.glassC || '#3A2A20', [sx * 0.5, 0.1, 0.38], 1, 'gloss');
arm.rotation.set(Math.PI / 2, 0, 0);
arm.rotation.y = sx * 0.55;
}
add(F, new THREE.CylinderGeometry(0.015, 0.015, 0.1, 6), o.glassC || '#3A2A20', [0, 0.11, 0.64], 1, 'gloss').rotation.z = Math.PI / 2;
}
if (o.mustache === 'handle') {
add(F, SPH, HC, [0, -0.19, 0.585], [0.14, 0.055, 0.055], 'hair');
for (const sx of [-1, 1]) {
const cv = new THREE.CatmullRomCurve3([[sx * 0.05, -0.19, 0.6], [sx * 0.17, -0.21, 0.565], [sx * 0.28, -0.15, 0.48], [sx * 0.32, -0.05, 0.43], [sx * 0.27, 0.0, 0.45]].map(p => new THREE.Vector3(...p)));
add(F, new THREE.TubeGeometry(cv, 24, 0.042, 10), HC, [0, 0, 0], 1, 'hair');
add(F, SPH, HC, [sx * 0.27, 0.0, 0.45], 0.045, 'hair');
}
}
if (o.mustache === 'chevron')
add(F, SPH, HC, [0, -0.2, 0.585], [0.21, 0.065, 0.06], 'hair');
if (o.beard) {
add(F, SPH, HC, [0, -0.38, 0.33], [0.25, 0.13, 0.17], 'hair');
for (const sx of [-1, 1])
add(F, SPH, HC, [sx * 0.4, -0.22, 0.3], [0.09, 0.16, 0.12], 'hair');
}
if (o.bindi)
add(F, SPH, '#E0115F', [0, 0.25, 0.56], [0.032, 0.032, 0.015], 'gloss');
if (o.earrings)
for (const sx of [-1, 1]) {
const e = add(F, new THREE.TorusGeometry(0.045, 0.012, 8, 20), '#E8C15A', [sx * 0.63, -0.2, 0.03], 1, 'metal');
e.rotation.y = Math.PI / 2;
}
if (o.bow)
for (const sx of [-1, 1]) {
const c = add(F, new THREE.ConeGeometry(0.11, 0.22, 16), o.bow, [0.34 + sx * 0.11, 0.5, 0.2], 1, 'toy');
c.rotation.z = sx * Math.PI / 2;
}
const face = {
F,
lids,
looks,
brows,
mouth: {
cav,
teeth,
tongue,
line
},
blush,
cheeks,
cur: Object.assign({}, EXPR.neutral),
tgt: Object.assign({}, EXPR.neutral),
nextBlink: nowS() + 1 + Math.random() * 3,
blinkUntil: 0,
until: 0
};
return {
root,
rig,
head,
body,
arms,
legs,
eyes: [],
pupils: [],
mouth: new THREE.Object3D(),
meshes,
outlines: [],
pickables,
face,
lines: o.lines || [],
idleExpr: 'neutral',
phase: Math.random() * 6.28,
nextBlink: 1e9,
blink: 0,
vy: 0,
squash: 0,
spinT: 0,
wave: 0,
baseRot: 0,
scale: 1,
tx: 0,
ty: 0,
tz: 0
};
}
const T = o => Object.assign({
toon: true
}, o);
const P = {
kidA: T({
name: 'Pinky',
skin: '#EDBB95',
hair: '#2B1B17',
hairStyle: 'braids',
ribbon: '#FF5A9E',
top: '#7B5CFF',
outfit: 'frock',
pants: '#FF8FB1',
shoe: '#FF5A9E',
eye: '#4A2C1E',
lines: ['I love colours! Aapke brand ka favourite colour kya hai? \ud83c\udfa8', 'Mere braids bhi animate hote hain, dekha? \ud83d\udc81\u200d\u2640\ufe0f', 'Cartoon banwao na, main dekhungi! \ud83d\udcfa']
}),
kidB: T({
name: 'Chintu',
skin: '#C98A62',
hair: '#16100E',
hairStyle: 'side',
backcap: '#2EC4B6',
top: '#FFC23C',
outfit: 'tee',
badge: '#7B5CFF',
pants: '#3D3B8E',
shoe: '#FFFFFF',
lines: ['Mujhe cartoon dekhna pasand hai. Aapke customers ko bhi! \ud83d\udcfa', 'Homework baad mein, pehle aapka project! \ud83d\ude0e', 'Main bada hoke animator banunga! \ud83c\udfac']
}),
kidC: T({
name: 'Sunita Aunty',
skin: '#E2AE8A',
hair: '#1E1412',
hairStyle: 'bun',
bindi: true,
earrings: true,
top: '#FF5A8A',
outfit: 'saree',
drape: '#FFC23C',
pants: '#C2185B',
shoe: '#C2185B',
lines: ['Sharma ji ka beta bhi yahin se animation banwata hai \ud83d\ude09', 'Beta, chai piyoge? Pehle project bhejo \u2615', 'Itna sundar ad dekh ke padosi jal jaayenge \ud83d\ude04']
}),
kidD: T({
name: 'Rohan',
skin: '#B87A56',
hair: '#120C0A',
hairStyle: 'messy',
beard: true,
headphones: true,
top: '#4CC9F0',
outfit: 'hoodie',
top2: '#2FA8CF',
pants: '#1B1340',
shoe: '#FF5A5F',
lines: ['Content is king. Animated content is emperor \ud83d\udc51', 'Reels ke liye hook chahiye? Ho jayega \ud83c\udfa3', 'Bro, ye 3D dekh ke followers pakka badhenge \ud83d\udcc8']
}),
kidE: T({
name: 'Gupta ji',
skin: '#D9A07A',
hair: '#2A1C16',
hairStyle: 'bald',
topi: '#8E1B2C',
mustache: 'handle',
glasses: true,
top: '#F2B544',
outfit: 'jacket',
jacket: '#7A4A2E',
pants: '#5B4636',
shoe: '#3A2A22',
lines: ['Beta, quality se koi compromise nahi! \ud83d\udc4c', 'Hamare zamane mein ads boring hote the. Ab nahi! \ud83d\ude04', 'Paisa vasool animation, aur muft mein smile \ud83d\ude01', 'Mooch pe taav, brand pe naav! \ud83d\ude0e']
}),
dadi: T({
name: 'Dadi',
skin: '#D8A483',
hair: '#EDEDED',
brow: '#D0D0D0',
hairStyle: 'bun',
glasses: true,
glassC: '#B08D57',
bindi: true,
top: '#8E5CC9',
outfit: 'shawl',
drape: '#C9A0FF',
pants: '#6B3FA0',
shoe: '#4A2A6B',
lines: ['Jeete raho beta! Aur WhatsApp karte raho \ud83d\ude04', 'Meri kahaniyan bhi animate karwa do na \ud83e\udd79', 'Khaana khaya? Accha, ab project bhi bhej do \ud83c\udf72']
}),
chef: T({
name: 'Chef Sharma',
skin: '#CF9670',
hair: '#1A1210',
hairStyle: 'short',
mustache: 'chevron',
chefHat: true,
top: '#FFFFFF',
outfit: 'apron',
apron: '#FF5A5F',
pants: '#2B2B3A',
shoe: '#1B1B24',
lines: ['Perfect recipe: idea + masala + animation \ud83c\udf5b', 'Ek plate 3D, extra tadka ke saath? \ud83d\udd25', 'Main tomato juggle karta hoon, aap ideas bhejo \ud83c\udf45']
}),
panda: T({
type: 'panda',
skin: '#FFFFFF',
top: '#FFFFFF',
sleeve: '#24212E',
hand: '#24212E',
pants: '#24212E',
shoe: '#24212E',
eye: '#3A2418',
lines: ['Panda hug for you! \ud83d\udc3c\ud83e\udd17', 'Bamboo chhod ke aapko dekhne aaya hoon \ud83c\udf8b', 'Main bhi kabhi sketch tha\u2026 ab full 3D! \ud83d\udc85']
}),
robot: {
type: 'robot',
skin: '#D5DDF0',
shirt: '#9FB4D9',
pants: '#6E7FA6',
shoe: '#4A5A80'
},
cat: {
type: 'cat',
skin: '#FFB347',
shirt: '#FFB347',
sleeve: '#FFB347',
pants: '#FF9A2E',
shoe: '#FFFFFF'
}
};
P.pandaBow = Object.assign({}, P.panda, {
bow: '#FF5A9E'
});
P.pandaDJ = Object.assign({}, P.panda, {
headphones: true
});
const CHARS = [P.kidA, P.kidB, P.kidE, P.kidC, P.kidD, P.dadi, P.chef, P.panda];
function setPose(c, o) {
const A = c.arms,
L = c.legs;
A[0].rotation.set(o.aLx || 0, 0, o.aL ?? -0.22);
A[1].rotation.set(o.aRx || 0, 0, o.aR ?? 0.22);
L[0].rotation.x = o.lL || 0;
L[1].rotation.x = o.lR || 0;
c.head.rotation.set(o.hx || 0, o.hy || 0, o.hz || 0);
}
/* ================= interactions: random reactions + bubbles ================= */
const LINES = ['Aapka smile dekh ke mera render fast ho gaya \ud83d\ude04', 'Arre waah! Aap toh full brand-owner vibes de rahe ho \ud83d\ude0e', 'Ek cartoon aapke business ka bhi banna chahiye. Agree? \ud83d\ude4b', 'Your idea + our animators = "Wow, who made this?!" \ud83e\udd29', 'Mujhe click karna band mat karna, accha lagta hai \ud83e\udd79', 'Psst\u2026 aapke paas ek mast idea hai na? Batao! \ud83d\udc42', 'Code se nahi, dil se animate karte hain \u2764\ufe0f', 'You look like someone who makes smart decisions \ud83d\ude09', 'Ek 10-second video, aur log poochenge "Kisne banaya?" \ud83d\udd25', 'Tickle mat karo! Achha theek hai\u2026 ek baar aur \ud83d\ude02', 'Aapne click kiya, maine smile kiya. Deal pakki? \ud83e\udd1d', 'Your competitors are still using stock photos. Just saying \ud83d\udc40', 'Animation = attention. Attention = customers. Simple! \ud83d\udcc8', 'I was made with love, chai and 1000 keyframes \u2615', 'Pehli nazar mein hi project ka idea aa gaya \ud83d\udca1', 'Stories stick. Boring banners don\u2019t. \ud83d\ude09', 'Aaj aapka din bahut accha jaane wala hai. Promise! \ud83c\udf08', 'Brand mascot banwa lo \u2014 log kabhi nahi bhoolenge \ud83d\udc3c', 'Quick question: aapka brand agar cartoon hota, toh kaisa dikhta? \ud83e\udd14', '2D pasand hai ya 3D? Main 3D hoon\u2026 toh obviously \ud83d\ude0f', 'Aapke customers Reels dekhte hain? Toh aapka Reel kab aa raha hai? \ud83d\udcf1', 'Main sirf 10 second mein dil jeet leta hoon \u23f1\ufe0f', 'Thank you for visiting! Aap bahut acche ho \ud83d\udc9c', 'Hindi ho ya English \u2014 dono mein dhamaal! \ud83c\udf99\ufe0f', 'Itni der se dekh rahe ho\u2026 pakka kuch banwana hai \ud83d\ude01', 'Hum deadline se nahi darte, deadline humse darti hai \ud83d\ude0e', 'Ek click aur\u2026 aapka brand bhi aise hi muskurayega \ud83d\ude0a'];
const EMOJI = ['\u2728', '\ud83d\udc9c', '\u2b50', '\ud83c\udfac', '\ud83c\udfa8', '\ud83c\udf89', '\ud83d\udca5', '\u2764\ufe0f', '\ud83c\udf08', '\ud83c\udf7f', '\ud83c\udfb5', '\ud83d\ude0d'];
const CTA_LINES = ['Free quote chahiye? Bas ek message door \ud83c\udf81', 'Shall we start your project today? \ud83d\ude80', 'Ready for your own cartoon star? \ud83c\udf1f', 'Chalo, aapka idea animate karte hain? \ud83c\udfac'];
function emojiBurst(x, y) {
if (reduce)
return;
const set = [pick(EMOJI), pick(EMOJI), pick(EMOJI)];
for (let i = 0; i e.remove();
}
}
function emojiHearts(x, y) {
for (let i = 0; i e.remove();
}
}
function makeBubble(text, withCta) {
const b = document.createElement('div');
b.className = 'cbub';
b.innerHTML = '
';
b.firstChild.textContent = text;
if (withCta) {
const a = document.createElement('a');
a.href = '#contact';
a.textContent = 'Yes, let\u2019s go \ud83d\udc49';
a.className = 'cbub-btn';
b.appendChild(a);
a.addEventListener('click', () => b.remove());
}
ROOT.appendChild(b);
requestAnimationFrame(() => b.classList.add('show'));
return b;
}
const REACTS = ['jump', 'spin', 'grow', 'shake', 'dance', 'jump'];
/* ================= HERO ================= */
function hero() {
const canvas = document.getElementById('heroCanvas'),
stage = document.getElementById('heroStage'),
bubble = document.getElementById('heroBubble'),
hint = document.getElementById('stageHint');
if (!matchMedia('(hover:hover)').matches)
hint.textContent = '\ud83d\udc46 Tap a character \u2014 something random happens!';
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: true,
powerPreference: 'high-performance'
});
setup(renderer);
renderer.setPixelRatio(Math.min(devicePixelRatio, 1.8));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene(),
camera = new THREE.PerspectiveCamera(32, 1, 0.1, 100);
scene.environment = envFor(renderer);
const {k: key} = lights(scene, {
hemi: .7,
keyI: 2.2,
keyP: [3, 8, 6],
rimI: 1.4
});
key.castShadow = true;
key.shadow.mapSize.set(1024, 1024);
Object.assign(key.shadow.camera, {
left: -6,
right: 6,
top: 6,
bottom: -4,
near: 1,
far: 25
});
key.shadow.radius = 6;
key.shadow.bias = -0.0005;
const disc = new THREE.Mesh(new THREE.CylinderGeometry(1, 1, 0.24, 96), M('#F2ECFF', 'toy'));
disc.position.y = -0.12;
disc.receiveShadow = true;
scene.add(disc);
const riser = new THREE.Mesh(new THREE.CylinderGeometry(1, 1, 1, 96), M('#E2D7FF', 'toy'));
riser.receiveShadow = true;
riser.castShadow = true;
scene.add(riser);
const sres = shadowRes();
const chars = CHARS.map((o, i) => {
const c = buildChar(o);
scene.add(c.root);
c.idx = i;
c.shadow = blob(scene, sres, 0, 0, 1);
c.pickables.forEach(m => m.userData.ci = i);
c.rig.position.y = reduce ? 0 : 5 + i * 0.45;
c.landed = false;
return c;
});
const pick3 = chars.flatMap(c => c.pickables);
const decor = new THREE.Group();
scene.add(decor);
const starShape = (() => {
const s = new THREE.Shape();
for (let i = 0; i {
const m = new THREE.Mesh(geo, M(c, 'toy'));
m.position.set(...p);
m.scale.setScalar(s);
m.userData = {
base: p.slice(),
ph: i * 1.3
};
decor.add(m);
return m;
});
const planet = new THREE.Group();
planet.add(O(new THREE.Mesh(SPH, M('#7B5CFF', 'toy')), {
scale: new THREE.Vector3(.42, .42, .42)
}));
const ring = new THREE.Mesh(new THREE.TorusGeometry(0.66, 0.05, 10, 48), M('#FFC23C', 'toy'));
ring.rotation.x = 1.2;
planet.add(ring);
planet.position.set(3.9, 4.8, -4.5);
planet.userData = {
base: [3.9, 4.8, -4.5],
ph: 2
};
decor.add(planet);
items.push(planet);
for (const [x, y, z, s] of [[-4.6, 3.2, -5, 1], [1.8, 6.2, -6, 1.2]]) {
const cg = new THREE.Group();
for (const [a, b, r] of [[0, 0, .45], [.45, .12, .36], [-.45, .05, .34], [.1, .3, .34]]) {
const m = new THREE.Mesh(SPH, M('#FFFFFF', 'fabric'));
m.position.set(a, b, 0);
m.scale.setScalar(r);
cg.add(m)
}
cg.position.set(x, y, z);
cg.scale.setScalar(s);
cg.userData = {
base: [x, y, z],
ph: x
};
decor.add(cg);
items.push(cg);
}
const confGeo = new THREE.PlaneGeometry(0.08, 0.13),
confCols = [0xFF5A5F, 0xFFC23C, 0x2EC4B6, 0x7B5CFF, 0x4CC9F0, 0xFF8FB1];
const conf = Array.from({
length: 70
}, (_, i) => {
const m = new THREE.Mesh(confGeo, new THREE.MeshBasicMaterial({
color: confCols[i % 6],
side: THREE.DoubleSide
}));
m.visible = false;
m.userData = {
v: new THREE.Vector3(),
life: 0,
spin: new THREE.Vector3()
};
scene.add(m);
return m;
});
let confI = 0;
function burst(p) {
for (let k = 0; k = 1.75;
if (one) {
chars.forEach((c, i) => {
const x = (i - 3.5) * 1.15;
c.tx = x;
c.tz = i % 2 ? 0.9 : 0.15;
c.ty = 0;
c.baseRot = -x * 0.07;
c.scale = 0.98
});
disc.scale.set(4.7, 1, 2.2);
disc.position.z = 0.5;
riser.visible = false;
W = 10.3;
H = 3.4;
look.set(0, 1.35, 0.4);
}
else {
const narrow = aspect {
const c = chars[ci];
c.tx = (k - 1.5) * sp;
c.tz = 1.2 + (k % 2 ? 0.35 : 0);
c.ty = 0;
c.baseRot = -c.tx * 0.08;
c.scale = 1
});
back.forEach((ci, k) => {
const c = chars[ci];
c.tx = (k - 1.5) * sp * 0.98;
c.tz = -0.95;
c.ty = 1.35;
c.baseRot = -c.tx * 0.06;
c.scale = 0.97
});
disc.scale.set(sp * 2.35, 1, 2.45);
disc.position.z = 0.35;
riser.visible = true;
riser.scale.set(sp * 2.4, 1.35, 1.1);
riser.position.set(0, 0.675, -0.95);
W = sp * 3 + (narrow ? 2.1 : 2.9);
H = 5.1;
look.set(0, 2.1, 0.3);
}
const vt = Math.tan(THREE.MathUtils.degToRad(camera.fov / 2));
camera.userData.d = Math.max((H / 2) / vt, (W / 2) / (vt * aspect)) * 1.04;
}
function resize() {
const w = stage.clientWidth,
h = stage.clientHeight;
if (!w || !h)
return;
renderer.setSize(w, h, false);
camera.aspect = w / h;
camera.updateProjectionMatrix();
applyLayout(w / h);
}
new ResizeObserver(resize).observe(stage);
resize();
chars.forEach(c => c.root.position.set(c.tx, c.ty, c.tz));
const ptr = {
active: false,
cx: innerWidth / 2,
cy: innerHeight / 2
};
addEventListener('pointermove', e => {
ptr.cx = e.clientX;
ptr.cy = e.clientY;
ptr.active = true
}, {
passive: true
});
const ray = new THREE.Raycaster(),
ndc = new THREE.Vector2(),
plane = new THREE.Plane(new THREE.Vector3(0, 0, 1), -4),
target = new THREE.Vector3(),
tmp = new THREE.Vector3();
let hovered = -1;
function ndcFrom(cx, cy) {
const r = canvas.getBoundingClientRect();
ndc.set(((cx - r.left) / r.width) * 2 - 1, -((cy - r.top) / r.height) * 2 + 1);
return r;
}
function hitTest(cx, cy) {
ndcFrom(cx, cy);
ray.setFromCamera(ndc, camera);
const h = ray.intersectObjects(pick3, false);
return h.length ? h[0].object.userData.ci : -1;
}
canvas.addEventListener('pointermove', e => {
if (e.pointerType === 'mouse')
hovered = hitTest(e.clientX, e.clientY)
});
canvas.addEventListener('pointerleave', () => hovered = -1);
let bubbleT = 0,
bubbleC = null;
canvas.addEventListener('pointerdown', e => {
const i = hitTest(e.clientX, e.clientY);
ptr.cx = e.clientX;
ptr.cy = e.clientY;
ptr.active = true;
if (i < 0)
return;
const c = chars[i];
const r = pick(REACTS);
c.react = {
type: r,
t0: performance.now() / 1000
};
if (r === 'jump' && c.rig.position.y < 0.05) {
c.vy = 7.2;
c.spinT += Math.PI * 2
}
const ex = pick(CLICK_EXPR);
setExpr(c, ex, 2.6);
c.talkUntil = nowS() + 1.2;
if (ex === 'love')
emojiHearts(e.clientX, e.clientY);
c.wave = 1.6;
c.head.getWorldPosition(tmp);
tmp.y += 0.6 * c.scale;
burst(tmp);
emojiBurst(e.clientX, e.clientY);
const cta = Math.random() < 0.18;
bubble.innerHTML = '';
const sp = document.createElement('span');
sp.textContent = cta ? pick(CTA_LINES) : (c.lines && c.lines.length && Math.random() {
visible = es[0].isIntersecting
}, {
threshold: 0
}).observe(stage);
const clock = new THREE.Clock();
let t = 0,
nextAuto = 2.5,
camX = 0;
function frame() {
requestAnimationFrame(frame);
const dt = Math.min(0.05, clock.getDelta());
if (!visible)
return;
t += dt;
if (ptr.active)
ndcFrom(ptr.cx, ptr.cy);
else
ndc.set(Math.sin(t * .5) * .6, Math.sin(t * .7) * .3);
ray.setFromCamera(ndc, camera);
ray.ray.intersectPlane(plane, target) || target.set(0, 2, 4);
camX = lerp(camX, clamp(ndc.x, -1.5, 1.5) * 0.35, 0.04);
const d = camera.userData.d || 10;
camera.position.set(camX, look.y + d * 0.13, d + look.z);
camera.lookAt(look.x, look.y, look.z);
if (!reduce && t > nextAuto) {
const c = chars[(Math.random() * chars.length) | 0];
if (c.wave 1)
c.react = null;
else {
if (c.react.type === 'grow')
rs *= 1 + Math.sin(p * Math.PI) * 0.35;
}
}
c.root.scale.setScalar(lerp(c.root.scale.x, rs, 0.2));
const r = c.rig;
c.vy -= 18 * dt;
r.position.y += c.vy * dt;
if (r.position.y <= 0) {
if (c.vy < -3) {
c.squash = Math.min(0.32, -c.vy * 0.035);
c.vy = -c.vy * 0.28;
if (c.vy < 1.4)
c.vy = 0;
} else
c.vy = 0;
r.position.y = Math.max(0, r.position.y);
if (r.position.y === 0 && c.vy === 0)
c.landed = true;
}
c.squash = lerp(c.squash, 0, 0.14);
const bob = reduce ? 0 : Math.sin(t * 2.4 + c.phase) * 0.025;
r.scale.set(1 + c.squash * 0.55, 1 - c.squash + bob * .6, 1 + c.squash * 0.55);
let spinExtra = 0,
rz = 0;
if (c.react) {
const p = (now - c.react.t0) / 1.4;
if (c.react.type === 'spin')
spinExtra = ease(clamp(p, 0, 1)) * Math.PI * 2;
if (c.react.type === 'shake')
rz = Math.sin(p * 40) * 0.18 * (1 - p);
if (c.react.type === 'dance') {
rz = Math.sin(p * 25) * 0.2;
r.position.x = Math.sin(p * 25) * 0.12;
}
}
else
r.position.x = lerp(r.position.x, 0, 0.2);
r.rotation.y = lerp(r.rotation.y, c.spinT, 0.09) + spinExtra * 0;
r.rotation.z = rz;
c.head.getWorldPosition(tmp);
tmp.y += 0.5 * c.scale;
const dx = target.x - tmp.x,
dy = target.y - tmp.y,
dz = target.z - tmp.z;
let yaw = Math.atan2(dx, dz) - c.baseRot,
pitch = -Math.atan2(dy, Math.hypot(dx, dz));
yaw = clamp(yaw, -1.1, 1.1);
pitch = clamp(pitch, -0.55, 0.45);
c.root.rotation.y = lerp(c.root.rotation.y, c.baseRot + yaw * 0.28, 0.08) + (spinExtra ? 0 : 0);
if (spinExtra)
c.root.rotation.y = c.baseRot + spinExtra;
c.head.rotation.y = lerp(c.head.rotation.y, yaw * 0.72, 0.14);
c.head.rotation.x = lerp(c.head.rotation.x, pitch, 0.14);
c.head.rotation.z = lerp(c.head.rotation.z, (reduce ? 0 : Math.sin(t * 1.3 + c.phase) * 0.05) - yaw * 0.06, 0.1);
for (const p of c.pupils) {
p.position.x = lerp(p.position.x, clamp(yaw, -1, 1) * 0.035, 0.2);
p.position.y = lerp(p.position.y, -pitch * 0.04, 0.2)
}
if (c.face)
updateFace(c, dt, yaw * 1.4, pitch * 1.4);
c.nextBlink -= dt;
if (c.nextBlink 0 ? 0.12 : 1;
for (const e of c.eyes) {
const b = e.userData.sy || 1;
e.scale.y = lerp(e.scale.y, ey * b, 0.6)
}
const air = r.position.y > 0.08,
isHover = hovered === c.idx;
if (isHover && c.wave 0 && sx === 1)
z = 2.55 + Math.sin(t * 14) * 0.32;
a.rotation.z = lerp(a.rotation.z, z, 0.2);
a.rotation.x = lerp(a.rotation.x, (c.wave > 0 && sx === 1) ? -0.3 : 0, 0.2)
}
const happy = (c.wave > 0 || air || c.react) ? 1 : 0;
c.mouth.scale.set(lerp(c.mouth.scale.x, 1 + happy * .35, .2), lerp(c.mouth.scale.y, 1 + happy * .9, .2), 1);
c.shadow.position.set(c.root.position.x, c.root.position.y + 0.012, c.root.position.z + 0.05);
const ss = (1 - Math.min(0.6, r.position.y * 0.18)) * c.scale;
c.shadow.scale.set(ss, ss, ss);
c.shadow.visible = c.landed || r.position.y = 0 ? 'pointer' : '';
for (const m of items) {
const b = m.userData.base,
ph = m.userData.ph;
m.position.set(b[0] + ndc.x * -0.25, b[1] + (reduce ? 0 : Math.sin(t * 1.1 + ph) * 0.18), b[2]);
m.rotation.y += dt * 0.6;
m.rotation.x = Math.sin(t * .7 + ph) * 0.3
}
for (const m of conf) {
if (!m.visible)
continue;
const u = m.userData;
u.life -= dt;
if (u.life 0) {
bubbleT -= dt;
bubbleC.head.getWorldPosition(tmp);
tmp.y += 1.35 * bubbleC.scale;
tmp.project(camera);
const w = stage.clientWidth,
h = stage.clientHeight,
bw = bubble.offsetWidth / 2 + 10;
bubble.style.left = clamp((tmp.x + 1) / 2 * w, bw, w - bw) + 'px';
bubble.style.top = clamp((1 - tmp.y) / 2 * h, bubble.offsetHeight + 14, h) + 'px';
if (bubbleT m.userData.mat = m.material);
table.userData.mat = table.material;
let mode = 2;
function setMode(k) {
mode = k;
modes.forEach((s, i) => s.classList.toggle('on', i === k));
[...kid.meshes, table].forEach(m => m.material = k === 0 ? wire : k === 1 ? clay : m.userData.mat)
}
modes.forEach((s, i) => s.addEventListener('click', () => {
setMode(i);
modeT = 0
}));
let modeT = 0;
function resize() {
const w = box.clientWidth,
h = box.clientHeight;
if (!w || !h)
return;
renderer.setSize(w, h, false);
camera.aspect = w / h;
camera.updateProjectionMatrix();
const vt = Math.tan(THREE.MathUtils.degToRad(15));
const d = Math.max(1.85 / vt, 1.7 / (vt * camera.aspect));
camera.position.set(0, 2.0, d);
camera.lookAt(0, 1.4, 0);
}
new ResizeObserver(resize).observe(box);
resize();
let rotY = 0,
vel = 0.6,
drag = false,
lastX = 0;
box.addEventListener('pointerdown', e => {
drag = true;
lastX = e.clientX
});
addEventListener('pointerup', () => drag = false);
box.addEventListener('pointermove', e => {
if (!drag)
return;
const dx = e.clientX - lastX;
lastX = e.clientX;
vel = dx * 0.6;
rotY += dx * 0.012
});
let visible = false;
new IntersectionObserver(es => {
visible = es[0].isIntersecting
}).observe(box);
const clock = new THREE.Clock();
let t = 0;
(function frame() {
requestAnimationFrame(frame);
const dt = Math.min(.05, clock.getDelta());
if (!visible)
return;
t += dt;
if (!drag) {
vel = lerp(vel, 0.6, 0.03);
rotY += vel * dt
}
kid.root.rotation.y = rotY;
table.rotation.y = rotY;
kid.head.rotation.x = Math.sin(t * 1.5) * 0.12;
kid.head.rotation.z = Math.sin(t * 1.1) * 0.08;
kid.arms[1].rotation.z = 2.5 + Math.sin(t * 10) * 0.3;
kid.arms[0].rotation.z = -0.25 + Math.sin(t * 2) * 0.05;
kid.rig.position.y = Math.abs(Math.sin(t * 2.6)) * 0.12;
kid.nextBlink -= dt;
if (kid.nextBlink e.scale.y = kid.blink > 0 ? .12 : 1);
if (t > nextE) {
setExpr(kid, pick(CLICK_EXPR), 1.6);
nextE = t + 2.2;
}
updateFace(kid, dt, Math.sin(t * 0.7) * 0.4, 0);
modeT += dt;
if (modeT > (mode === 2 ? 3.6 : 2.2)) {
modeT = 0;
setMode((mode + 1) % 3)
}
renderer.render(scene, camera);
})();
}
/* ================= props for section characters ================= */
function stripeTex(a, b, n=8, diag=false) {
return canvasTex(128, 128, (x, w, h) => {
x.fillStyle = a;
x.fillRect(0, 0, w, h);
x.fillStyle = b;
for (let i = 0; i < n; i++) {
if (diag) {
x.save();
x.translate(i * w / n * 2 - w / 2, 0);
x.transform(1, 0, -.6, 1, 0, 0);
x.fillRect(0, 0, w / n, h);
x.restore();
} else
x.fillRect(i * w / n, 0, w / n / 2, h);
}
});
}
function sofa(color) {
const g = new THREE.Group();
mk(RB(2.4, 0.42, 1.0, 0.16), color, 'fabric', [0, 0.36, 0], g);
mk(RB(2.4, 0.92, 0.34, 0.16), color, 'fabric', [0, 0.86, -0.43], g);
for (const s of [-1, 1])
mk(RB(0.34, 0.64, 1.04, 0.15), color, 'fabric', [s * 1.19, 0.55, 0], g);
for (const sx of [-1, 1])
for (const sz of [-1, 1])
mk(new THREE.CylinderGeometry(0.05, 0.035, 0.16, 12), '#6B4A2A', 'toy', [sx * 1.05, 0.08, sz * 0.38], g);
for (const s of [-1, 1]) {
const c = mk(RB(0.5, 0.42, 0.16, 0.08), '#FFFFFF', 'fabric', [s * 0.95, 0.8, -0.2], g);
c.rotation.z = s * 0.15;
}
return g;
}
function popcorn() {
const g = new THREE.Group();
const b = new THREE.Mesh(new THREE.CylinderGeometry(0.17, 0.12, 0.34, 28), new THREE.MeshPhysicalMaterial({
map: stripeTex('#ffffff', '#E63946', 6),
roughness: .4,
clearcoat: .6
}));
b.castShadow = true;
g.add(b);
for (let i = 0; i {
x.fillStyle = '#D62839';
x.fillRect(0, 0, 256, 64);
x.fillStyle = '#fff';
x.font = '700 34px Fredoka, sans-serif';
x.textAlign = 'center';
x.fillText('DIRECTOR', 128, 45);
});
const lab = new THREE.Mesh(new THREE.PlaneGeometry(0.8, 0.2), new THREE.MeshStandardMaterial({
map: tx,
roughness: .8
}));
lab.position.set(0, 1.02, -0.302);
g.add(lab);
return g;
}
function clapper() {
const g = new THREE.Group();
mk(RB(0.4, 0.28, 0.03, 0.01), '#1B1340', 'toy', [0, 0, 0], g);
const st = new THREE.Mesh(RB(0.4, 0.06, 0.031, 0.005), new THREE.MeshPhysicalMaterial({
map: stripeTex('#1B1340', '#ffffff', 8, true),
roughness: .4,
clearcoat: .5
}));
st.position.set(0, 0.11, 0);
g.add(st);
const arm = new THREE.Group();
arm.position.set(-0.2, 0.15, 0);
g.add(arm);
const a = new THREE.Mesh(RB(0.4, 0.06, 0.03, 0.005), st.material);
a.position.set(0.2, 0.03, 0);
arm.add(a);
return {
g,
arm
};
}
function micStand() {
const g = new THREE.Group();
mk(new THREE.CylinderGeometry(0.22, 0.25, 0.04, 32), '#2A2840', 'metal', [0, 0.02, 0], g);
mk(new THREE.CylinderGeometry(0.018, 0.018, 1.42, 10), '#3A3856', 'metal', [0, 0.73, 0], g);
const head = new THREE.Group();
head.position.set(0, 1.48, 0);
head.rotation.x = 0.5;
g.add(head);
mk(new THREE.CapsuleGeometry(0.065, 0.12, 8, 16), '#C5CCDA', 'metal', [0, 0.06, 0], head);
mk(new THREE.CylinderGeometry(0.045, 0.045, 0.16, 16), '#2A2840', 'metal', [0, -0.07, 0], head);
return g;
}
function noteMesh(color) {
const g = new THREE.Group();
mk(SPH, color, 'toy', [0, 0, 0], g, [0.06, 0.045, 0.04]);
mk(new THREE.CylinderGeometry(0.008, 0.008, 0.17, 6), color, 'toy', [0.05, 0.085, 0], g);
mk(RB(0.06, 0.025, 0.012, 0.005), color, 'toy', [0.08, 0.16, 0], g);
return g;
}
function easel() {
const g = new THREE.Group();
const board = new THREE.Group();
board.position.set(0, 1.45, 0);
board.rotation.x = -0.08;
g.add(board);
mk(RB(1.38, 1.03, 0.04, 0.03), '#9AA3B5', 'metal', [0, 0, -0.02], board);
mk(RB(1.3, 0.95, 0.05, 0.025), '#FFFFFF', 'gloss', [0, 0, 0], board);
for (const [x, z, rx, rz] of [[-0.5, 0.12, -0.12, 0.08], [0.5, 0.12, -0.12, -0.08], [0, -0.35, 0.3, 0]]) {
const l = mk(new THREE.CylinderGeometry(0.025, 0.025, 1.9, 8), '#8B5A2B', 'toy', [x, 0.95, z], g);
l.rotation.set(rx, 0, rz);
}
const strokes = [];
const mkStroke = (pts, color, r=0.018) => {
const curve = new THREE.CatmullRomCurve3(pts.map(p => new THREE.Vector3(p[0], p[1], 0.035)));
const geo = new THREE.TubeGeometry(curve, 64, r, 6, false);
const m = new THREE.Mesh(geo, M(color, 'toy'));
board.add(m);
strokes.push({
m,
count: geo.index.count
});
return m;
};
mkStroke(Array.from({
length: 12
}, (_, i) => [-0.5 + i * 0.09, 0.22 + Math.sin(i * 0.9) * 0.08]), '#FF5A5F');
mkStroke(Array.from({
length: 20
}, (_, i) => {
const a = i / 19 * Math.PI * 1.9;
return [0.3 + Math.cos(a) * 0.15, -0.12 + Math.sin(a) * 0.15]
}), '#4C6FFF');
mkStroke([[-0.5, -0.3], [-0.3, -0.1], [-0.1, -0.25], [0.05, -0.05]], '#2EC4B6');
return {
g,
strokes
};
}
function beret(c) {
const b = new THREE.Mesh(SPH, M('#1B1340', 'fabric'));
b.position.set(0.06, 1.08, -0.02);
b.scale.set(0.5, 0.13, 0.5);
b.rotation.z = 0.22;
b.castShadow = true;
c.head.add(b);
const s = new THREE.Mesh(SPH, M('#1B1340', 'fabric'));
s.scale.setScalar(0.05);
s.position.set(0.04, 1.2, 0);
c.head.add(s);
}
/* ================= section-character animation ================= */
function animate(c, T, yawC, pitC, dt, s) {
const A = c.arms,
L = c.legs;
let px = 0,
py = 0,
ry = 0,
rz = 0,
sx = 1,
sy = 1,
hx = 0,
hy = 0,
hz = 0,
aL = -0.22,
aR = 0.22,
aLx = 0,
aRx = 0,
lL = 0,
lR = 0,
look = 1,
smile = 0.2;
const sit = () => {
lL = -1.45 + Math.sin(T * 2.2) * 0.18;
lR = -1.45 - Math.sin(T * 2.2) * 0.18;
py = 0.01;
};
switch (c.act) {
case 'wave':
{
py = Math.abs(Math.sin(T * 2.4)) * 0.05;
aR = 2.55 + Math.sin(T * 12) * 0.35;
aRx = -0.2;
hz = Math.sin(T * 2) * 0.12;
const k = T % 4;
if (k {
const u = T * 0.95 + i / 3,
ph = u % 1,
dir = Math.floor(u) % 2 ? 1 : -1;
b.position.set(c.root.position.x + dir * 0.8 * Math.cos(ph * Math.PI), 1.1 + Math.sin(ph * Math.PI) * 2.4, 0.45)
});
break;
}
case 'phone':
{
const up = (T % 5) > 3.4;
aL = 0.35;
aLx = -1.25;
aR = -0.35;
aRx = -1.25 + Math.sin(T * 18) * 0.05;
hx = 0.35;
look = 0.15;
if (up) {
aR = 2.5 + Math.sin(T * 12) * 0.3;
aRx = -0.2;
hx = -0.05;
look = 1;
smile = 0.7
}
py = Math.abs(Math.sin(T * 2)) * 0.02;
break;
}
case 'think':
{
aR = -0.5;
aRx = -2.3;
aL = -0.25;
hz = 0.2 + Math.sin(T * 1.2) * 0.06;
hy = 0.25;
hx = -0.1;
look = 0.4;
smile = 0;
c.th.forEach((b, i) => {
const ph = (T * 0.45 + i / 3) % 1;
b.position.set(c.root.position.x + 0.55 + ph * 0.3, 2.75 + ph * 0.8, 0.1);
b.scale.setScalar((0.07 + ph * 0.09) * Math.sin(ph * Math.PI) + 0.001)
});
break;
}
case 'sofa':
{
sit();
const k = (T + c.idx * 2.3) % 7;
aL = -0.3;
aR = 0.3;
aLx = -0.5;
aRx = -0.5;
smile = 0.4;
if (k 4 && k < 5.4) {
rz = Math.sin(T * 30) * 0.05;
smile = 1.2;
hx = -0.15;
if (!c.face || c.face.name !== 'laugh' || c.face.until - nowS() 4.2) {
hx = -0.05;
look = 1;
smile = 0.8;
if (!c.react)
setExpr(c, 'happy', 0.3);
aR = 2.4 + Math.sin(T * 12) * 0.3;
aRx = -0.2;
}
break;
}
case 'director':
{
sit();
const k = T % 3.2;
aRx = -1.3;
aR = -0.1;
aL = -0.35;
aLx = -0.4;
if (k > 2.3 && k < 2.9) {
aL = -2.3;
aLx = -0.2;
smile = 1
}
hx = 0.05;
if (c.clap) {
const q = k < 2.6 ? -0.7 : k < 2.7 ? lerp(-0.7, 0, (k - 2.6) / 0.1) : 0;
c.clap.arm.rotation.z = k < 2.6 ? -0.6 * seg(k, 1.6, 2.4) : (k {
const ph = (T * 0.4 + i / c.notes.length) % 1;
n.position.set(c.root.position.x + 0.35 + Math.sin(ph * 6 + i) * 0.25, 1.9 + ph * 1.3, 0.3);
n.scale.setScalar(Math.sin(ph * Math.PI) * 1.2 + 0.001);
n.rotation.z = Math.sin(ph * 8) * 0.4;
});
break;
}
case 'draw':
{
const k = T % 7;
ry = 0.9;
look = 0.3;
aRx = -1.55 + Math.sin(T * 5) * 0.12;
aR = 0.15 + Math.cos(T * 5) * 0.12;
hx = 0.05;
hy = 0.1;
if (k > 5.3) {
ry = 0.25;
aRx = -0.2;
aR = 2.45 + Math.sin(T * 12) * 0.3;
look = 1;
hy = 0;
smile = 0.8;
if (!c.react)
setExpr(c, 'happy', 0.3);
}
if (c.strokes) {
const p = seg(T % 7, 0, 4.5);
const n = c.strokes.length;
c.strokes.forEach((st, i) => {
const q = clamp(p * n - i, 0, 1);
st.m.geometry.setDrawRange(0, Math.floor(st.count * q / 6) * 6);
});
}
break;
}
}
if (c.react) {
const p = (performance.now() / 1000 - c.react.t0) / 1.4;
if (p > 1)
c.react = null;
else {
const ty = c.react.type;
if (ty === 'spin')
ry += ease(p) * Math.PI * 2;
if (ty === 'jump') {
py += Math.sin(p * Math.PI) * (c.sitting ? 0.35 : 0.7);
aL = -2.4;
aR = 2.4;
smile = 1.2;
}
if (ty === 'grow') {
const g = 1 + Math.sin(p * Math.PI) * 0.3;
sx *= g;
sy *= g;
}
if (ty === 'shake')
rz += Math.sin(p * 40) * 0.18 * (1 - p);
if (ty === 'dance') {
px += Math.sin(p * 25) * 0.1;
rz += Math.sin(p * 25) * 0.15;
aL = -(1.5 + Math.sin(p * 30));
aR = 1.5 - Math.sin(p * 30);
smile = 1;
}
}
}
const r = c.rig;
r.position.set(px, py, 0);
r.rotation.set(0, ry, rz);
r.scale.set(sx, sy, sx);
const k = Math.min(1, dt * 14);
A[0].rotation.z = lerp(A[0].rotation.z, aL, k);
A[1].rotation.z = lerp(A[1].rotation.z, aR, k);
A[0].rotation.x = lerp(A[0].rotation.x, aLx, k);
A[1].rotation.x = lerp(A[1].rotation.x, aRx, k);
L[0].rotation.x = lerp(L[0].rotation.x, lL, k);
L[1].rotation.x = lerp(L[1].rotation.x, lR, k);
c.head.rotation.y = lerp(c.head.rotation.y, hy + yawC * look, k * 0.6);
c.head.rotation.x = lerp(c.head.rotation.x, hx + pitC * look, k * 0.6);
c.head.rotation.z = lerp(c.head.rotation.z, hz, k);
c.root.rotation.y = lerp(c.root.rotation.y, c.base + yawC * 0.25 * look, k * 0.4);
c.nextBlink -= dt;
if (c.nextBlink 0 ? 0.12 * b : b
}
for (const p of c.pupils) {
p.position.x = clamp(yawC, -1, 1) * 0.035 * look;
p.position.y = -pitC * 0.04 * look
}
c.mouth.scale.y = lerp(c.mouth.scale.y, 1 + smile, k);
c.mouth.scale.x = lerp(c.mouth.scale.x, 1 + smile * 0.3, k);
if (c.face)
updateFace(c, dt, yawC * look * 1.4, pitC * look * 1.4);
if (c.sh) {
const ss = 1 - Math.min(0.6, py * 0.45);
c.sh.scale.set(ss, ss, ss);
c.sh.position.x = c.root.position.x + px;
}
}
/* ================= 3D FILMS (10-second loops) ================= */
const FILM_D = 10;
function filmBase(stops, fog) {
const scene = new THREE.Scene();
scene.add(skyDome(stops));
if (fog)
scene.fog = fog;
const cam = new THREE.PerspectiveCamera(35, 16 / 9, 0.1, 200);
scene.add(cam);
const fade = new THREE.Mesh(new THREE.PlaneGeometry(10, 10), new THREE.MeshBasicMaterial({
color: 0x000000,
transparent: true,
opacity: 0,
depthTest: false,
depthWrite: false,
fog: false
}));
fade.position.z = -0.5;
fade.renderOrder = 999;
cam.add(fade);
return {
scene,
cam,
fade
};
}
function titleCard(cam, lines, opts={}) {
const tex = canvasTex(1024, 576, (x, w, h) => {
x.textAlign = 'center';
lines.forEach(l => {
x.font = l.font;
x.fillStyle = l.color || '#fff';
x.shadowColor = 'rgba(0,0,0,.55)';
x.shadowBlur = 24;
if (l.spacing)
x.letterSpacing = l.spacing;
x.fillText(l.text, w / 2, l.y);
});
});
const m = new THREE.Mesh(new THREE.PlaneGeometry(1, 1), new THREE.MeshBasicMaterial({
map: tex,
transparent: true,
opacity: 0,
depthTest: false,
depthWrite: false,
fog: false
}));
m.renderOrder = 1000;
m.position.z = -1;
cam.add(m);
m.userData.fit = (a) => {
const h = 2 * Math.tan(THREE.MathUtils.degToRad(cam.fov / 2));
m.scale.set(h * 16 / 9, h, 1);
if (a < 16 / 9)
m.scale.set(h * a, h * a / (16 / 9), 1);
};
return m;
}
function fadeIO(f, t, inEnd=0.35, outStart=9.55) {
f.material.opacity = Math.max(1 - seg(t, 0, inEnd), seg(t, outStart, FILM_D));
}
function camPath(cam, t, keys) {
let i = 0;
while (i keys[i + 1][0])
i++;
const [t0, p0, l0] = keys[i],
[t1, p1, l1] = keys[i + 1];
const q = ease(seg(t, t0, t1));
cam.position.set(lerp(p0[0], p1[0], q), lerp(p0[1], p1[1], q), lerp(p0[2], p1[2], q));
cam.lookAt(lerp(l0[0], l1[0], q), lerp(l0[1], l1[1], q), lerp(l0[2], l1[2], q));
}
function swayGrass(n, area, colors, h=0.5) {
const geo = new THREE.ConeGeometry(0.03, h, 3);
geo.translate(0, h / 2, 0);
const mat = new THREE.MeshStandardMaterial({
roughness: .9
});
const u = {
value: 0
};
mat.onBeforeCompile = (sh) => {
sh.uniforms.uTime = u;
sh.vertexShader = 'uniform float uTime;\n' + sh.vertexShader.replace('#include ', '#include \nfloat wph = instanceMatrix[3].x*0.7+instanceMatrix[3].z*0.4; transformed.x += sin(uTime*1.7+wph)*0.12*position.y; transformed.z += cos(uTime*1.3+wph)*0.05*position.y;');
};
const im = new THREE.InstancedMesh(geo, mat, n);
const o = new THREE.Object3D(),
c = new THREE.Color();
for (let i = 0; i {
const m = new THREE.Mesh(geo, mat);
m.position.set(...p);
if (s)
m.scale.set(...s);
m.castShadow = true;
parent.add(m);
return m;
};
const hips = new THREE.Group();
hips.position.y = 0.95;
g.add(hips);
const legs = [-1, 1].map(sx => {
const l = new THREE.Group();
l.position.set(sx * 0.11, 0, 0);
hips.add(l);
part(new THREE.CapsuleGeometry(0.075, 0.42, 6, 12), [0, -0.26, 0], l);
part(new THREE.CapsuleGeometry(0.065, 0.4, 6, 12), [0, -0.7, 0], l);
part(RB(0.12, 0.07, 0.24, 0.03), [0, -0.93, 0.05], l);
return l;
});
const torso = new THREE.Group();
hips.add(torso);
part(new THREE.CapsuleGeometry(0.17, 0.38, 8, 16), [0, 0.32, 0], torso, [1.15, 1, 0.75]);
part(SPH, [0, 0.75, 0], torso, [0.105, 0.13, 0.115]);
part(new THREE.CylinderGeometry(0.045, 0.05, 0.1, 10), [0, 0.63, 0], torso);
for (const sx of [-1, 1])
part(SPH, [sx * 0.22, 0.55, 0], torso, [0.1, 0.08, 0.1]);
const arms = [-1, 1].map(sx => {
const a = new THREE.Group();
a.position.set(sx * 0.24, 0.54, 0);
torso.add(a);
part(new THREE.CapsuleGeometry(0.055, 0.3, 6, 10), [0, -0.2, 0], a);
const fore = new THREE.Group();
fore.position.y = -0.4;
a.add(fore);
part(new THREE.CapsuleGeometry(0.048, 0.28, 6, 10), [0, -0.18, 0], fore);
part(SPH, [0, -0.36, 0], fore, [0.05, 0.06, 0.04]);
a.userData.fore = fore;
return a;
});
return {
g,
hips,
torso,
legs,
arms,
mat
};
}
const FILMS = {
/* ---- 1. Savanna sunrise (Lion-King style 3D short) ---- */
savanna() {
const {scene, cam, fade} = filmBase([[0, '#3B2A6B'], [.38, '#C8577A'], [.5, '#FF9E5E'], [.56, '#FFD08A'], [1, '#C98A4B']], new THREE.Fog('#F4A86C', 14, 70));
scene.add(new THREE.HemisphereLight('#FFD8A8', '#6B4A2A', 0.9));
const sun = new THREE.DirectionalLight('#FFB070', 3.2);
sun.position.set(-20, 6, -30);
scene.add(sun);
const fill = new THREE.DirectionalLight('#FFE9D0', 0.9);
fill.position.set(6, 8, 10);
scene.add(fill);
const sunG = glow('#FFE2A6', 22, 1);
sunG.position.set(-14, 2.6, -40);
scene.add(sunG);
const sunC = glow('#FFFFFF', 6, 1);
sunC.position.copy(sunG.position);
scene.add(sunC);
const gg = new THREE.PlaneGeometry(200, 200, 80, 80);
gg.rotateX(-Math.PI / 2);
const pos = gg.attributes.position;
for (let i = 0; i {
const m = new THREE.Mesh(new THREE.DodecahedronGeometry(1, 1), M('#8C6B57', 'flat'));
m.position.set(...p);
m.scale.set(...s);
m.rotation.set(...r);
rock.add(m);
};
rk([3, 1, -1], [3.2, 2.6, 2.6], [.2, .3, .1]);
rk([4.6, 0.6, 1], [2.2, 1.6, 2], [0, .8, .2]);
rk([1.4, 2.3, -0.2], [2.6, 0.55, 1.25], [0, 0, 0.06]);
rk([2.8, 2.0, -0.6], [1.6, 0.9, 1.4], [.3, .2, 0]);
rk([-0.2, 2.42, 0], [1.0, 0.3, 0.8], [0, 0, -0.05]);
for (const [x, z, s] of [[-12, -26, 1.4], [-6, -30, 1], [14, -24, 1.6], [22, -32, 1.2]]) {
const tr = new THREE.Group();
const tk = new THREE.Mesh(new THREE.CylinderGeometry(0.12 * s, 0.2 * s, 3 * s, 8), M('#4A3426', 'matte'));
tk.position.y = 1.5 * s;
tr.add(tk);
const cp = new THREE.Mesh(SPH, M('#3F4A28', 'matte'));
cp.scale.set(2.6 * s, 0.5 * s, 1.6 * s);
cp.position.y = 3.1 * s;
tr.add(cp);
tr.position.set(x, 0, z);
scene.add(tr);
}
// lion cub
const cub = new THREE.Group();
scene.add(cub);
const fur = '#D9A35C',
lightF = '#F3D3A0';
const bodyG = new THREE.Mesh(new THREE.CapsuleGeometry(0.3, 0.5, 10, 20), M(fur, 'fabric'));
bodyG.rotation.z = Math.PI / 2;
bodyG.position.y = 0.55;
cub.add(bodyG);
const bel = new THREE.Mesh(SPH, M(lightF, 'fabric'));
bel.scale.set(0.45, 0.22, 0.26);
bel.position.set(0, 0.42, 0);
cub.add(bel);
const cl = [];
for (const [x, z] of [[0.32, 0.15], [0.32, -0.15], [-0.32, 0.15], [-0.32, -0.15]]) {
const l = new THREE.Group();
l.position.set(x, 0.45, z);
cub.add(l);
const m = new THREE.Mesh(new THREE.CapsuleGeometry(0.085, 0.25, 6, 12), M(fur, 'fabric'));
m.position.y = -0.18;
l.add(m);
const pw = new THREE.Mesh(SPH, M(lightF, 'fabric'));
pw.scale.set(0.1, 0.07, 0.12);
pw.position.set(0.02, -0.36, 0);
l.add(pw);
cl.push(l);
}
const tail = new THREE.Mesh(new THREE.TubeGeometry(new THREE.CatmullRomCurve3([new THREE.Vector3(-0.55, 0.62, 0), new THREE.Vector3(-0.85, 0.75, 0), new THREE.Vector3(-1.0, 1.0, 0)]), 20, 0.035, 8), M(fur, 'fabric'));
cub.add(tail);
const tuft = new THREE.Mesh(SPH, M('#7A4A2A', 'fabric'));
tuft.scale.setScalar(0.08);
tuft.position.set(-1.0, 1.02, 0);
cub.add(tuft);
const hd = new THREE.Group();
hd.position.set(0.55, 0.92, 0);
hd.rotation.y = 0.9;
cub.add(hd);
const ruff = new THREE.Mesh(SPH, M('#C27A3A', 'fabric'));
ruff.scale.set(0.4, 0.42, 0.33);
ruff.position.z = -0.06;
hd.add(ruff);
hd.add(O(new THREE.Mesh(SPH, M(fur, 'fabric')), {
scale: new THREE.Vector3(0.36, 0.34, 0.34)
}));
const muz = new THREE.Mesh(SPH, M(lightF, 'fabric'));
muz.scale.set(0.17, 0.12, 0.12);
muz.position.set(0, -0.1, 0.27);
hd.add(muz);
const nose = new THREE.Mesh(SPH, M('#4A2A1E', 'gloss'));
nose.scale.set(0.055, 0.04, 0.04);
nose.position.set(0, -0.03, 0.38);
hd.add(nose);
const jaw = new THREE.Mesh(SPH, M('#5A1A2B', 'toy'));
jaw.scale.set(0.07, 0.02, 0.05);
jaw.position.set(0, -0.17, 0.33);
hd.add(jaw);
for (const sx of [-1, 1]) {
const e = new THREE.Mesh(SPH, M('#FFFFFF', 'gloss'));
e.scale.set(0.075, 0.09, 0.05);
e.position.set(sx * 0.13, 0.05, 0.29);
hd.add(e);
const ir = new THREE.Mesh(SPH, M('#8A5A1A', 'gloss'));
ir.scale.set(0.05, 0.065, 0.03);
ir.position.set(sx * 0.13, 0.04, 0.33);
hd.add(ir);
const pu = new THREE.Mesh(SPH, M('#120A05', 'gloss'));
pu.scale.set(0.028, 0.04, 0.02);
pu.position.set(sx * 0.13, 0.04, 0.355);
hd.add(pu);
const hl = new THREE.Mesh(SPH, M('#FFFFFF', 'glow'));
hl.scale.setScalar(0.014);
hl.position.set(sx * 0.13 + 0.015, 0.07, 0.37);
hd.add(hl);
const ear = new THREE.Mesh(SPH, M(fur, 'fabric'));
ear.scale.set(0.1, 0.1, 0.05);
ear.position.set(sx * 0.24, 0.26, -0.02);
hd.add(ear);
const tf = new THREE.Mesh(SPH, M('#B5652B', 'fabric'));
tf.scale.set(0.06, 0.09, 0.06);
tf.position.set(sx * 0.05, 0.34, 0.02);
hd.add(tf);
}
cub.traverse(m => {
if (m.isMesh)
m.castShadow = true
});
const birds = [];
for (let i = 0; i 0 && walk l.rotation.z = wk ? Math.sin(t * 9 + (i % 2 ? Math.PI : 0) + (i > 1 ? Math.PI / 2 : 0)) * 0.5 : 0);
bodyG.position.y = 0.55 + (wk ? Math.abs(Math.sin(t * 9)) * 0.03 : 0);
const roar = seg(t, 7.4, 7.7) * (1 - seg(t, 8.7, 9.1));
hd.rotation.x = -roar * 0.55;
hd.rotation.y = lerp(0.9, 0.5, roar);
jaw.scale.y = 0.02 + roar * 0.09 * (0.8 + Math.sin(t * 30) * 0.2);
jaw.position.y = -0.17 - roar * 0.05;
tail.rotation.x = Math.sin(t * 2) * 0.2;
tuft.position.y = 1.02 + Math.sin(t * 2) * 0.05;
birds.forEach(b => {
const u = b.userData,
burst = seg(t, 7.9, 10);
b.position.set(u.x0 - t * u.sp * (1 + burst * 3), u.y0 + burst * 3 + Math.sin(t + u.ph) * 0.3, u.z0);
b.children.forEach(pv => pv.rotation.z = pv.userData.s * Math.sin(t * (8 + burst * 8) + u.ph) * 0.6);
});
motes.rotation.y = t * 0.05;
camPath(cam, t, [[0, [-9, 1.4, 11], [1, 2.4, -2]], [3, [-6.5, 1.8, 9], [1.5, 2.5, -1]], [3.01, [-1.2, 3.25, 5.6], [2, 3.2, 0]], [7, [0.2, 3.1, 4.6], [0.4, 3.3, 0]], [7.01, [-1.1, 2.75, 2.7], [0.3, 3.6, 0]], [8.6, [-1.0, 2.9, 2.9], [0.3, 3.7, 0]], [8.61, [-5, 6, 12], [1, 3, 0]], [10, [-6, 6.8, 13.5], [1, 3, 0]]]);
fadeIO(fade, t);
}
};
},
/* ---- 2. Panda's bamboo day ---- */
bamboo() {
const {scene, cam, fade} = filmBase([[0, '#CFEAD0'], [.5, '#EAF5DA'], [1, '#7FA86A']], new THREE.Fog('#D8EDD0', 5, 30));
lights(scene, {
sky: '#F5FFE8',
ground: '#4E7A3A',
hemi: 1.1,
key: '#FFF2D6',
keyI: 2.2,
keyP: [4, 8, 3],
rim: '#E8FFD0',
rimI: 1.4
});
const gr = new THREE.Mesh(new THREE.CircleGeometry(40, 48), M('#6FA35B', 'matte'));
gr.rotation.x = -Math.PI / 2;
scene.add(gr);
scene.add(swayGrass(1400, [-8, 8, -8, 6], ['#5E9A48', '#7DB65A', '#4F8A3C'], 0.35));
const stalk = (x, z, h) => {
const g = new THREE.Group();
for (let y = 0; y < h; y += 0.9) {
const s = new THREE.Mesh(new THREE.CylinderGeometry(0.09, 0.1, 0.86, 14), M('#86B84E', 'toy'));
s.position.y = y + 0.45;
g.add(s);
const n = new THREE.Mesh(new THREE.TorusGeometry(0.1, 0.022, 8, 20), M('#6E9E3A', 'toy'));
n.rotation.x = Math.PI / 2;
n.position.y = y + 0.88;
g.add(n);
}
for (let i = 0; i < 5; i++) {
const lf = new THREE.Mesh(new THREE.ConeGeometry(0.06, 0.5, 4), M('#5FA03E', 'toy'));
lf.scale.z = 0.25;
lf.position.set(rnd(-.2, .2), rnd(h * 0.5, h), rnd(-.2, .2));
lf.rotation.z = rnd(-1.4, -0.6) * (Math.random() < .5 ? 1 : -1);
g.add(lf);
}
g.position.set(x, 0, z);
g.rotation.z = rnd(-.05, .05);
scene.add(g);
};
for (let i = 0; i < 34; i++) {
const a = rnd(0, Math.PI * 2),
r = rnd(2.2, 9);
stalk(Math.cos(a) * r, Math.sin(a) * r - 1, rnd(4, 8));
}
for (let i = 0; i {
const pv = new THREE.Group();
const w = new THREE.Mesh(new THREE.CircleGeometry(0.08, 16), new THREE.MeshStandardMaterial({
color: '#FF8A3D',
side: THREE.DoubleSide,
roughness: .5
}));
w.position.x = s * 0.08;
w.scale.y = 0.8;
pv.add(w);
bf.add(pv);
return pv;
});
bf.add(O(new THREE.Mesh(new THREE.CapsuleGeometry(0.012, 0.08, 4, 8), M('#2A1A10', 'toy')), {
rotation: new THREE.Euler(Math.PI / 2, 0, 0)
}));
scene.add(bf);
const motes = points(120, [-4, 4, 0.5, 4, -3, 3], '#FFF7C2', 0.06);
scene.add(motes);
const nosePos = new THREE.Vector3();
return {
scene,
cam,
cues: [[0, 'music', 'gentle'], [0.6, 'chirp'], [3.8, 'chirp'], [8.05, 'sneeze']],
update(t, dt, a) {
const chew = (t % 2.2) / 2.2,
sneeze = seg(t, 7.7, 8.05) * (1 - seg(t, 8.3, 8.8));
setPose(pd, {
lL: -1.45,
lR: -1.45,
aL: -0.35,
aLx: -0.6,
aR: -0.45,
aRx: -1.6 - Math.sin(chew * Math.PI) * 0.6,
hx: -0.05 + Math.sin(t * 6) * 0.03 * (t < 5.5 ? 1 : 0) - sneeze * 0.35,
hz: Math.sin(t * 1.2) * 0.06
});
pd.rig.position.y = 0.02;
pd.rig.scale.set(1 + sneeze * 0.08, 1 - sneeze * 0.1, 1 + sneeze * 0.08);
pd.mouth.scale.y = 1 + Math.abs(Math.sin(t * 9)) * 0.6 * (t < 5.5 ? 1 : 0) + sneeze * 1.2;
const bl = (t % 3.6) 8 && t e.scale.y = bl ? 0.12 : 1);
pd.talkUntil = t 7.55 && t = 8.05 && t 5.6 ? 'love' : 'happy', 0.2);
updateFace(pd, dt, 0, t > 5.6 && t {
p.position.y = t > 5.6 && t 5.6 && t < 8 ? 0 : Math.sin(t) * 0.02;
});
pd.head.updateMatrixWorld(true);
nosePos.set(0, 0.47, 0.75).applyMatrix4(pd.head.matrixWorld);
if (t < 5.6) {
const a2 = t * 1.4;
bf.position.set(Math.cos(a2) * 1.3, 1.7 + Math.sin(t * 3) * 0.3, Math.sin(a2) * 1.0 + 0.3);
bf.position.lerp(nosePos, seg(t, 4.6, 5.6));
}
else if (t 5.6 && t w.rotation.y = (i ? 1 : -1) * Math.sin(t * (fl < 1 ? 6 : 28)) * 1.1 * fl);
motes.rotation.y = t * 0.04;
const ang = lerp(-0.6, 0.45, t / 10),
rad = lerp(4.6, 2.6, ease(seg(t, 4.2, 6))) * (1 + 0.3 * seg(t, 8.6, 10));
cam.position.set(Math.sin(ang) * rad, lerp(1.7, 1.9, seg(t, 4, 6)), Math.cos(ang) * rad);
cam.lookAt(0, lerp(1.1, 1.75, ease(seg(t, 4.2, 6))), 0);
fadeIO(fade, t);
}
};
},
/* ---- 3. Robo & the tiny moon ---- */
robomoon() {
const {scene, cam, fade} = filmBase([[0, '#05031A'], [.6, '#1A1050'], [1, '#3A1E6E']]);
lights(scene, {
sky: '#9FB0FF',
ground: '#1A1040',
hemi: .6,
key: '#FFF2E0',
keyI: 2.4,
keyP: [5, 6, 4],
rim: '#7CF0FF',
rimI: 2.2,
rimP: [-4, 3, -4]
});
const stars = points(900, [-60, 60, -20, 50, -70, -20], '#FFFFFF', 0.5);
scene.add(stars);
const earth = new THREE.Mesh(SPH, M('#3B7DD8', 'toy'));
earth.scale.setScalar(3);
earth.position.set(-9, 7, -26);
scene.add(earth);
const eg = glow('#7CC4FF', 11, 0.7);
eg.position.copy(earth.position);
scene.add(eg);
const land = new THREE.Mesh(SPH, M('#4FBF7A', 'toy'));
land.scale.set(1.6, 1.2, 1);
land.position.set(-8.4, 7.8, -23.6);
scene.add(land);
const planet = new THREE.Group();
scene.add(planet);
planet.add(O(new THREE.Mesh(new THREE.SphereGeometry(3, 64, 48), M('#B9B2D8', 'toy'))));
for (let i = 0; i 4.7 && t < 8);
planet.rotation.x += walking ? dt * 0.35 : 0;
const b = t * 7;
if (walking)
setPose(bot, {
lL: Math.sin(b) * 0.55,
lR: -Math.sin(b) * 0.55,
aLx: -Math.sin(b) * 0.6,
aRx: Math.sin(b) * 0.6
});
else if (t e.scale.y = (t % 3 6.2 && t 0 && sp 0 && sp new THREE.Vector2(p[0], p[1]));
const bottle = new THREE.Group();
scene.add(bottle);
const body = new THREE.Mesh(new THREE.LatheGeometry(prof, 64), new THREE.MeshPhysicalMaterial({
color: '#FFB703',
roughness: .08,
clearcoat: 1,
clearcoatRoughness: .03,
transmission: 0,
ior: 1.4,
sheen: .2
}));
bottle.add(body);
const lbl = canvasTex(1024, 256, (x, w, h) => {
x.fillStyle = '#FFF8EC';
x.fillRect(0, 0, w, h);
x.fillStyle = '#FF5A5F';
x.font = '800 120px Fredoka, sans-serif';
x.textAlign = 'center';
x.fillText('MANGO FIZZ', w / 2, 150);
x.fillStyle = '#2EC4B6';
x.font = '600 46px "Plus Jakarta Sans", sans-serif';
x.fillText('sparkling \u00b7 100% fruit', w / 2, 215);
});
const label = new THREE.Mesh(new THREE.CylinderGeometry(0.475, 0.475, 0.5, 64, 1, true), new THREE.MeshPhysicalMaterial({
map: lbl,
roughness: .35,
clearcoat: .6
}));
label.position.y = 0.55;
bottle.add(label);
const cap = new THREE.Mesh(new THREE.CylinderGeometry(0.19, 0.19, 0.18, 32), M('#2EC4B6', 'metal'));
cap.position.y = 1.88;
bottle.add(cap);
bottle.traverse(m => {
if (m.isMesh)
m.castShadow = true
});
const mango = () => {
const g = new THREE.Group();
const f = new THREE.Mesh(SPH, new THREE.MeshPhysicalMaterial({
color: '#FFB300',
roughness: .3,
clearcoat: .8,
sheen: .6,
sheenColor: new THREE.Color('#FF6B35')
}));
f.scale.set(0.3, 0.36, 0.28);
g.add(f);
const lf = new THREE.Mesh(SPH, M('#3FA34D', 'toy'));
lf.scale.set(0.05, 0.16, 0.02);
lf.position.set(0.06, 0.38, 0);
lf.rotation.z = -0.6;
g.add(lf);
return g;
};
const mangos = [0, 1, 2].map(() => {
const m = mango();
scene.add(m);
return m;
});
const drops = Array.from({
length: 70
}, () => {
const d = new THREE.Mesh(SPH, M('#FFB703', 'gloss'));
d.scale.setScalar(rnd(.03, .07));
d.userData = {
v: new THREE.Vector3(rnd(-1.6, 1.6), rnd(2.5, 5), rnd(-1.6, 1.6))
};
scene.add(d);
return d;
});
const sweep = new THREE.Mesh(new THREE.PlaneGeometry(0.25, 4), new THREE.MeshBasicMaterial({
color: '#ffffff',
transparent: true,
opacity: 0.35,
blending: THREE.AdditiveBlending,
depthWrite: false
}));
sweep.rotation.z = 0.4;
scene.add(sweep);
const bubbles = points(60, [-0.35, 0.35, 0.1, 1.3, -0.35, 0.35], '#FFF4C2', 0.05);
bottle.add(bubbles);
const end = titleCard(cam, [{
text: 'MANGO FIZZ',
font: '800 96px Fredoka, sans-serif',
y: 120
}, {
text: 'Sip the summer.',
font: '600 44px "Plus Jakarta Sans", sans-serif',
y: 180,
color: '#FFE08A'
}]);
return {
scene,
cam,
cues: [[0, 'music', 'ad'], [0.15, 'whoosh'], [1.15, 'thud'], [1.6, 'whoosh'], [6.0, 'splash'], [8.0, 'chime']],
update(t, dt, a) {
end.userData.fit(a);
end.material.opacity = seg(t, 8, 8.5) * (1 - seg(t, 9.6, 10));
const drop = seg(t, 0, 1.15);
bottle.position.y = t 1.15 && t < 1.6 ? Math.sin(seg(t, 1.15, 1.6) * Math.PI) * 0.12 : 0;
bottle.scale.set(1 + sq * 0.6, 1 - sq, 1 + sq * 0.6);
bottle.rotation.y = t {
const inT = seg(t, 1.5 + i * 0.15, 2.4 + i * 0.15),
a2 = t * 1.3 + i * 2.09;
const r = lerp(6, 1.45, ease(inT));
m.position.set(Math.cos(a2) * r, 0.9 + Math.sin(t * 2 + i) * 0.25 + (1 - inT) * 3, Math.sin(a2) * r);
m.rotation.set(t + i, t * 1.3, 0);
m.visible = t > 1.4 && t {
const q = t - 6.0;
d.visible = q > 0 && q 0 && sw 5.9 && t 5.9 && t < 6.4 ? t * 20 : 0;
ringG.material.emissiveIntensity = 1 + Math.sin(t * 4) * 0.4;
const o = t * 0.25;
camPath(cam, t, [[0, [0, 2.2, 6.5], [0, 1.6, 0]], [1.2, [0, 1.3, 4.6], [0, 1.0, 0]], [6, [1.8, 1.2, 3.6], [0, 1.0, 0]], [8, [0, 1.1, 5.6], [0, 1.6, 0]], [10, [0, 1.1, 5.8], [0, 1.6, 0]]]);
cam.position.x += Math.sin(o) * 0.4;
fadeIO(fade, t);
}
};
},
/* ---- 5. Twinkle Twinkle (3D nursery rhyme) ---- */
twinkle() {
const {scene, cam, fade} = filmBase([[0, '#0B0A33'], [.55, '#2B2370'], [1, '#5E3FA8']]);
lights(scene, {
sky: '#B8B0FF',
ground: '#1B1340',
hemi: .9,
key: '#FFF0C0',
keyI: 2,
keyP: [2, 6, 6],
rim: '#9FD8FF',
rimI: 1.8
});
scene.add(points(700, [-40, 40, 2, 30, -40, -10], '#FFFFFF', 0.35));
const hill = new THREE.Mesh(SPH, M('#2F7A5A', 'matte'));
hill.scale.set(7, 2.2, 5);
hill.position.set(0, -1.4, 0);
scene.add(hill);
const hill2 = new THREE.Mesh(SPH, M('#235E48', 'matte'));
hill2.scale.set(10, 3, 6);
hill2.position.set(-6, -2, -8);
scene.add(hill2);
const moon = new THREE.Mesh(SPH, M('#FFF2C4', 'emis'));
moon.scale.setScalar(1.1);
moon.position.set(7, 7, -14);
scene.add(moon);
const mg = glow('#FFE9A8', 7, 0.6);
mg.position.copy(moon.position);
scene.add(mg);
const sh = new THREE.Shape();
for (let i = 0; i {
const e = new THREE.Mesh(SPH, M('#1B1340', 'gloss'));
e.scale.set(0.09, 0.13, 0.06);
e.position.set(sx * 0.22, 0.12, 0.36);
star.add(e);
const h = new THREE.Mesh(SPH, M('#FFFFFF', 'glow'));
h.scale.setScalar(0.03);
h.position.set(sx * 0.22 + 0.03, 0.17, 0.41);
star.add(h);
return e;
});
for (const sx of [-1, 1]) {
const ck = new THREE.Mesh(SPH, M('#FF8FAB', 'skin'));
ck.scale.set(0.09, 0.06, 0.03);
ck.position.set(sx * 0.4, -0.04, 0.34);
star.add(ck);
}
const smouth = new THREE.Mesh(SPH, M('#7A1A2B', 'toy'));
smouth.scale.set(0.1, 0.05, 0.05);
smouth.position.set(0, -0.12, 0.38);
star.add(smouth);
star.position.set(0, 4.1, -1.5);
const kids = [[P.kidA, -1.2], [P.kidB, 1.2]].map(([o, x]) => {
const c = buildChar(o);
c.root.position.set(x, 0.75, 1.2);
c.root.scale.setScalar(0.8);
scene.add(c.root);
return c;
});
const lantern = new THREE.Group();
const lb = new THREE.Mesh(RB(0.18, 0.24, 0.18, 0.04), M('#FFC23C', 'emis'));
lantern.add(lb);
const lg = glow('#FFD27A', 1.4, 0.8);
lantern.add(lg);
kids[1].arms[0].add(lantern);
lantern.position.set(0, -0.72, 0);
const flies = points(70, [-5, 5, 0.6, 3.5, -2, 3], '#E8FF7A', 0.14);
scene.add(flies);
const words = ['Twin', 'kle,', 'twin', 'kle,', 'lit', 'tle', 'star,', 'How', 'I', 'won', 'der', 'what', 'you', 'are!'];
const starts = [];
{
let tt = 0.4;
for (let i = 0; i < 14; i++) {
starts.push(tt);
tt += (i === 6 || i === 13) ? 1.2 : 0.6;
}
}
const cv = document.createElement('canvas');
cv.width = 1024;
cv.height = 576;
const cx = cv.getContext('2d');
const tex = new THREE.CanvasTexture(cv);
tex.colorSpace = THREE.SRGBColorSpace;
const hudM = new THREE.Mesh(new THREE.PlaneGeometry(1, 1), new THREE.MeshBasicMaterial({
map: tex,
transparent: true,
depthTest: false,
depthWrite: false,
fog: false
}));
hudM.renderOrder = 1000;
hudM.position.z = -1;
cam.add(hudM);
let lastW = -2;
function drawLyrics(wi) {
cx.clearRect(0, 0, 1024, 576);
const line = wi w + ((i s + cx.measureText(p).width, 0);
const bw = tw + 70;
cx.fillStyle = 'rgba(15,10,45,.55)';
cx.beginPath();
cx.roundRect((1024 - bw) / 2, 478, bw, 76, 38);
cx.fill();
let x = (1024 - tw) / 2;
parts.forEach((p, i) => {
cx.fillStyle = (off + i) <= wi ? '#FFD23F' : '#FFFFFF';
cx.fillText(p, x, 518);
x += cx.measureText(p).width;
});
tex.needsUpdate = true;
}
return {
scene,
cam,
cues: [[0, 'music', 'twinkle']],
update(t, dt, a) {
const hh = 2 * Math.tan(THREE.MathUtils.degToRad(cam.fov / 2));
hudM.scale.set(hh * 16 / 9, hh, 1);
let wi = -1;
for (let i = 0; i = starts[i])
wi = i;
if (wi !== lastW) {
drawLyrics(Math.max(wi, 0));
lastW = wi;
}
const sing = wi >= 0 && t - starts[wi] e.scale.y = (t % 3.4) {
const sw = Math.sin(t * Math.PI / 1.2 + i * Math.PI) * 0.12;
c.rig.rotation.z = sw;
setPose(c, {
aL: i ? -0.6 : -2.4 + Math.sin(t * 5) * 0.3,
aR: i ? 2.3 + Math.sin(t * 5) * 0.3 : 0.4,
hx: -0.4,
hz: -sw * 0.5
});
c.mouth.scale.y = sing ? 1.8 : 1;
setExpr(c, 'happy', 0.3);
c.talkUntil = sing ? nowS() + 0.1 : 0;
updateFace(c, dt, 0, -0.6);
});
flies.rotation.y = t * 0.1;
flies.position.y = Math.sin(t) * 0.1;
cam.position.set(Math.sin(t * 0.12) * 1.2, lerp(2.2, 2.6, t / 10), lerp(7.5, 6.6, t / 10));
cam.lookAt(0, 2.6, 0);
fadeIO(fade, t);
}
};
},
/* ---- 6. Dance party music video ---- */
dance() {
const {scene, cam, fade} = filmBase([[0, '#12052E'], [1, '#3A0E5E']]);
lights(scene, {
sky: '#C8B0FF',
ground: '#12052E',
hemi: .7,
key: '#FFFFFF',
keyI: 2.2,
rim: '#FF5AE0',
rimI: 2.5
});
const st = new THREE.Mesh(new THREE.CylinderGeometry(4, 4.2, 0.3, 64), new THREE.MeshPhysicalMaterial({
color: '#2A1450',
roughness: .15,
clearcoat: 1
}));
st.position.y = -0.15;
scene.add(st);
const neon = new THREE.Mesh(new THREE.TorusGeometry(4.05, 0.05, 8, 128), M('#FF5AE0', 'emis'));
neon.rotation.x = Math.PI / 2;
scene.add(neon);
const ball = new THREE.Mesh(new THREE.IcosahedronGeometry(0.6, 2), new THREE.MeshStandardMaterial({
color: '#ffffff',
metalness: 1,
roughness: .12,
flatShading: true
}));
ball.position.set(0, 4.6, -0.5);
scene.add(ball);
const beams = ['#FF5A5F', '#4CC9F0', '#FFC23C', '#7B5CFF'].map((c, i) => {
const b = new THREE.Mesh(new THREE.ConeGeometry(0.9, 8, 24, 1, true), new THREE.MeshBasicMaterial({
color: c,
transparent: true,
opacity: .13,
blending: THREE.AdditiveBlending,
depthWrite: false,
side: THREE.DoubleSide
}));
b.geometry.translate(0, -4, 0);
b.position.set(-3 + i * 2, 7, -2);
scene.add(b);
return b;
});
const crew = [[P.kidA, -1.4], [P.panda, 0], [P.kidD, 1.4]].map(([o, x]) => {
const c = buildChar(o);
c.root.position.set(x, 0, 0);
scene.add(c.root);
return c;
});
const confG = new THREE.PlaneGeometry(0.07, 0.12),
cc = [0xFF5A5F, 0xFFC23C, 0x2EC4B6, 0x7B5CFF, 0x4CC9F0, 0xFF8FB1];
const conf = Array.from({
length: 120
}, (_, i) => {
const m = new THREE.Mesh(confG, new THREE.MeshBasicMaterial({
color: cc[i % 6],
side: THREE.DoubleSide
}));
m.userData = {
x: rnd(-5, 5),
z: rnd(-3, 3),
s: rnd(.6, 1.4),
o: rnd(0, 8)
};
scene.add(m);
return m;
});
const sparks = points(120, [-6, 6, 0, 6, -4, 2], '#FFFFFF', 0.12);
scene.add(sparks);
return {
scene,
cam,
cues: [[0, 'music', 'dance']],
update(t, dt, a) {
const beat = t * 124 / 60 * Math.PI;
crew.forEach((c, i) => {
const q = Math.sin(beat + (i === 1 ? Math.PI : 0));
setPose(c, {
aL: -(1.5 + q * 1.1),
aR: 1.5 - q * 1.1,
lL: -Math.max(0, q) * 0.6,
lR: -Math.max(0, -q) * 0.6,
hz: -Math.sin(beat / 2) * 0.18
});
c.rig.position.y = Math.abs(q) * 0.16;
c.rig.rotation.y = t > 5 && t 5 && t {
b.rotation.z = Math.sin(t * 1.4 + i) * 0.5;
b.rotation.x = Math.cos(t * 1.1 + i) * 0.3;
});
neon.material.color.setHSL((t * 0.1) % 1, 0.9, 0.6);
neon.material.emissive.copy(neon.material.color);
conf.forEach(m => {
const u = m.userData,
y = 6 - ((t * u.s + u.o) % 7);
m.position.set(u.x + Math.sin(t + u.o) * 0.3, y, u.z);
m.rotation.set(t * 3 * u.s, t * 2, t);
});
sparks.rotation.y = t * 0.3;
const bounce = Math.abs(Math.sin(beat)) * 0.06;
cam.position.set(Math.sin(t * 0.4) * 2.2, 1.9 + bounce, lerp(7.2, 6, seg(t, 0, 5)) + (t > 6.5 ? -1.2 * ease(seg(t, 6.5, 8)) : 0));
cam.lookAt(0, 1.4, 0);
fadeIO(fade, t);
}
};
},
/* ---- 7. AI film glimpse: The Last Guardian ---- */
warrior() {
const {scene, cam, fade} = filmBase([[0, '#0A0F1C'], [.5, '#2A3448'], [.62, '#4A566E'], [1, '#141A26']], new THREE.FogExp2('#1E2635', 0.06));
const hemi = new THREE.HemisphereLight('#6A7A99', '#0A0D14', 0.5);
scene.add(hemi);
const rim = new THREE.DirectionalLight('#9FC4FF', 2.2);
rim.position.set(-2, 5, -8);
scene.add(rim);
const key = new THREE.DirectionalLight('#C8D4F0', 0.4);
key.position.set(4, 3, 6);
scene.add(key);
const flashL = new THREE.PointLight('#D8E6FF', 0, 60);
flashL.position.set(-2, 9, -6);
scene.add(flashL);
const cliff = new THREE.Group();
scene.add(cliff);
for (const [p, s] of [[[0, -1.2, 0], [3.2, 1.6, 2.4]], [[2.5, -2, -1], [3, 2, 2.6]], [[-2.4, -2.2, -0.5], [2.4, 2, 2]]]) {
const m = new THREE.Mesh(new THREE.DodecahedronGeometry(1, 1), M('#1A1E28', 'flat'));
m.position.set(...p);
m.scale.set(...s);
cliff.add(m);
}
for (let i = 0; i < 5; i++) {
const m = new THREE.Mesh(new THREE.DodecahedronGeometry(1, 0), M('#0F131C', 'flat'));
m.position.set(rnd(-14, 14), rnd(-2, 2), rnd(-30, -16));
m.scale.set(rnd(3, 6), rnd(4, 9), rnd(3, 5));
scene.add(m);
}
const hero = humanoid('#14161E');
hero.g.position.set(0, 0.35, 0);
hero.g.scale.setScalar(1.25);
scene.add(hero.g);
const capeG = new THREE.PlaneGeometry(0.6, 1.25, 10, 16);
capeG.translate(0, -0.62, 0);
const cape = new THREE.Mesh(capeG, new THREE.MeshStandardMaterial({
color: '#4A0E14',
roughness: .7,
side: THREE.DoubleSide
}));
cape.position.set(0, 0.56, -0.13);
hero.torso.add(cape);
const cp0 = capeG.attributes.position.array.slice();
const sword = new THREE.Group();
sword.add(O(new THREE.Mesh(new THREE.BoxGeometry(0.035, 0.95, 0.01), new THREE.MeshStandardMaterial({
color: '#C8D4E8',
metalness: 1,
roughness: .15
})), {
position: new THREE.Vector3(0, 0.55, 0)
}));
sword.add(O(new THREE.Mesh(new THREE.BoxGeometry(0.22, 0.03, 0.04), M('#3A2A1A', 'metal')), {
position: new THREE.Vector3(0, 0.06, 0)
}));
sword.position.set(0, -0.36, 0.02);
sword.rotation.x = Math.PI;
hero.arms[1].userData.fore.add(sword);
const swordGlow = glow('#BFD8FF', 0.8, 0);
sword.add(swordGlow);
swordGlow.position.y = 1.0;
const rainN = 2200,
rg = new THREE.BufferGeometry(),
rp = new Float32Array(rainN * 6);
for (let i = 0; i < rainN; i++) {
const x = rnd(-12, 12),
y = rnd(-2, 14),
z = rnd(-10, 8);
rp.set([x, y, z, x + 0.06, y - 0.5, z], i * 6);
}
rg.setAttribute('position', new THREE.BufferAttribute(rp, 3));
const rain = new THREE.LineSegments(rg, new THREE.LineBasicMaterial({
color: '#9FB3D0',
transparent: true,
opacity: .35
}));
scene.add(rain);
const boltPts = [];
{
let p = new THREE.Vector3(-3, 14, -10);
for (let i = 0; i {
const d = t - x;
return d > 0 && d < 0.5 ? (d 0.12 && d 0.5;
boltG.material.opacity = f;
rim.intensity = 2.2 + f * 3;
const ra = rain.geometry.attributes.position.array;
for (let i = 0; i < rainN; i++) {
let y = ra[i * 6 + 1] - dt * 14;
if (y < -2)
y += 16;
ra[i * 6 + 1] = y;
ra[i * 6 + 4] = y - 0.5;
}
rain.geometry.attributes.position.needsUpdate = true;
const cp = capeG.attributes.position.array;
for (let i = 0; i < cp.length; i += 3) {
const yy = cp0[i + 1];
cp[i + 2] = cp0[i + 2] - Math.abs(yy) * 0.5 - Math.sin(t * 7 + yy * 5 + cp0[i] * 4) * 0.09 * Math.abs(yy) * 2;
cp[i] = cp0[i] + Math.sin(t * 5 + yy * 4) * 0.04 * Math.abs(yy);
}
capeG.attributes.position.needsUpdate = true;
capeG.computeVertexNormals();
const raise = ease(seg(t, 6.6, 7.15));
hero.arms[1].rotation.set(-raise * 2.9, 0, -0.15 + raise * 0.1);
hero.arms[1].userData.fore.rotation.x = -0.3 * (1 - raise);
hero.arms[0].rotation.set(0.15, 0, 0.25);
hero.torso.rotation.x = -raise * 0.08;
hero.torso.children[1].rotation.x = 0;
hero.torso.rotation.y = Math.sin(t * 0.5) * 0.05;
swordGlow.material.opacity = f * 1.2 + raise * 0.3;
camPath(cam, t, [[0, [0.8, 0.6, 7.5], [0, 1.6, 0]], [6.4, [0.5, 0.9, 4.4], [0, 1.9, 0]], [7.2, [1.6, 0.4, 3.2], [0, 2.6, 0]], [10, [1.9, 0.5, 3.6], [0, 2.6, 0]]]);
cam.position.x += Math.sin(t * 13) * 0.004 * f * 10;
fadeIO(fade, t);
}
};
},
/* ---- 8. AI film glimpse: Kurukshetra ---- */
archer() {
const {scene, cam, fade} = filmBase([[0, '#1A0505'], [.45, '#6E1A0E'], [.58, '#E0582A'], [.64, '#FFB05A'], [1, '#200806']], new THREE.FogExp2('#5A2414', 0.045));
scene.add(new THREE.HemisphereLight('#FF9A5A', '#1A0505', 0.6));
const back = new THREE.DirectionalLight('#FF8A3D', 3);
back.position.set(0, 3, -10);
scene.add(back);
const key = new THREE.DirectionalLight('#FFD2A0', 0.5);
key.position.set(4, 3, 6);
scene.add(key);
const sunG = glow('#FFB05A', 18, 0.9);
sunG.position.set(2, 2, -40);
scene.add(sunG);
const ground = new THREE.Mesh(new THREE.PlaneGeometry(200, 200), M('#2A0F08', 'matte'));
ground.rotation.x = -Math.PI / 2;
scene.add(ground);
for (let i = 0; i < 14; i++) {
const f = humanoid('#120604');
f.g.position.set(rnd(-16, 16), 0, rnd(-26, -12));
f.g.scale.setScalar(rnd(.9, 1.2));
f.g.rotation.y = rnd(-.5, .5);
scene.add(f.g);
}
const ch = new THREE.Group();
scene.add(ch);
const dk = '#1A0A06';
ch.add(O(new THREE.Mesh(RB(1.8, 0.6, 1.1, 0.08), M(dk, 'toy')), {
position: new THREE.Vector3(0, 0.9, 0)
}));
for (const sz of [-1, 1]) {
const w = new THREE.Mesh(new THREE.TorusGeometry(0.62, 0.07, 10, 32), M('#3A1E10', 'toy'));
w.position.set(-0.2, 0.62, sz * 0.62);
ch.add(w);
for (let k = 0; k new THREE.Vector3(...p))), 40, 0.02, 6), M('#3A1E10', 'toy'));
archer.arms[0].userData.fore.add(bow);
const strG = new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3()]);
const str = new THREE.Line(strG, new THREE.LineBasicMaterial({
color: '#FFD2A0'
}));
scene.add(str);
const arrows = [0, 1, 2, 3, 4].map(() => {
const g = new THREE.Group();
g.add(O(new THREE.Mesh(new THREE.CylinderGeometry(0.012, 0.012, 0.9, 6), M('#2A1208', 'toy')), {
rotation: new THREE.Euler(0, 0, Math.PI / 2)
}));
const fire = glow('#FFB05A', 0.7, 1);
fire.position.x = 0.45;
g.add(fire);
const tr = glow('#FF6A1A', 0.5, 0.5);
tr.scale.set(2.2, 0.18, 1);
tr.position.x = -0.6;
g.add(tr);
g.visible = false;
scene.add(g);
return g;
});
const embers = points(500, [-10, 10, 0, 8, -12, 6], '#FF9A3A', 0.1);
scene.add(embers);
const smoke = Array.from({
length: 10
}, () => {
const s = new THREE.Sprite(new THREE.SpriteMaterial({
map: glowTex,
color: '#3A1A12',
transparent: true,
opacity: .5,
depthWrite: false
}));
s.scale.setScalar(rnd(6, 12));
s.position.set(rnd(-14, 14), rnd(1, 4), rnd(-24, -8));
scene.add(s);
return s;
});
const title = titleCard(cam, [{
text: 'KURUKSHETRA',
font: '800 74px "Plus Jakarta Sans", sans-serif',
y: 280,
spacing: '12px',
color: '#FFE2C0'
}, {
text: 'AN AI FILM \u00b7 GLIMPSE',
font: '500 26px "Plus Jakarta Sans", sans-serif',
y: 330,
spacing: '8px',
color: '#FFB07A'
}]);
const hA = new THREE.Vector3(),
hB = new THREE.Vector3(),
tip = new THREE.Vector3(),
bowTop = new THREE.Vector3(),
bowBot = new THREE.Vector3();
return {
scene,
cam,
cues: [[0, 'music', 'war'], [3.15, 'arrow'], [6.35, 'arrow'], [6.55, 'arrow']],
update(t, dt, a) {
title.userData.fit(a);
title.material.opacity = seg(t, 8.3, 8.9) * (1 - seg(t, 9.6, 10));
ch.position.x = lerp(-1, 1, t / 10);
ch.position.y = Math.abs(Math.sin(t * 9)) * 0.02;
ch.userData['w1'].rotation.z = ch.userData['w-1'].rotation.z = -t * 3;
const fp = flagG.attributes.position.array;
for (let i = 0; i < fp.length; i += 3) {
fp[i + 2] = Math.sin(t * 9 + fp0[i] * 8) * 0.08 * fp0[i] * 2;
}
flagG.attributes.position.needsUpdate = true;
const draw = t < 3.15 ? ease(seg(t, 0.8, 2.9)) : t {
const q = t - shots[i];
ar.visible = q > 0 && q s.position.x += dt * 0.2 * (i % 2 ? 1 : -1));
const follow = seg(t, 3.15, 4.2) * (1 - seg(t, 4.4, 5.0));
camPath(cam, t, [[0, [3.5, 1.6, 5.2], [0, 1.8, 0]], [3.1, [2.2, 2.0, 3.6], [0, 2.3, 0]], [5, [4.2, 2.2, 6], [1, 2.2, -1]], [8, [2.6, 2.4, 4.2], [0.5, 2.4, 0]], [10, [2.8, 2.6, 4.6], [0.5, 2.4, 0]]]);
if (follow > 0) {
cam.position.x += follow * 3;
cam.lookAt(lerp(0, 8, follow), lerp(2.3, 4, follow), 0);
}
fadeIO(fade, t);
}
};
}
};
/* ================= shared renderer for section characters + films ================= */
function slots() {
const cv = document.createElement('canvas');
cv.id = 'slotCanvas';
cv.setAttribute('aria-hidden', 'true');
cv.style.cssText = 'position:fixed;left:0;top:0;pointer-events:none;z-index:50';
ROOT.appendChild(cv);
const renderer = new THREE.WebGLRenderer({
canvas: cv,
antialias: true,
alpha: true
});
setup(renderer);
renderer.setPixelRatio(Math.min(devicePixelRatio, 1.5));
renderer.setClearColor(0x000000, 0);
renderer.setScissorTest(true);
renderer.autoClear = false;
const env = envFor(renderer);
let vw = 0,
vh = 0;
function size() {
vw = document.documentElement.clientWidth;
vh = innerHeight;
cv.style.width = vw + 'px';
cv.style.height = vh + 'px';
renderer.setSize(vw, vh, false)
}
addEventListener('resize', size);
size();
const sres = shadowRes();
const list = [],
mouse = {
x: innerWidth / 2,
y: innerHeight * 0.35
};
addEventListener('pointermove', e => {
mouse.x = e.clientX;
mouse.y = e.clientY
}, {
passive: true
});
const ray = new THREE.Raycaster(),
nd = new THREE.Vector2(),
tmp = new THREE.Vector3();
function buildChars(s) {
const el = s.el,
names = (el.dataset.char || 'panda').split(','),
act = el.dataset.act || 'wave';
const scene = new THREE.Scene();
scene.environment = env;
lights(scene, {
hemi: .75,
keyI: 2.3,
rimI: 1.8
});
const cam = new THREE.PerspectiveCamera(30, 1, 0.1, 60),
n = names.length,
sp = act === 'sofa' ? 1.1 : 1.35;
const props = new THREE.Group();
scene.add(props);
if (act === 'sofa') {
props.add(sofa(el.dataset.color || '#FF8FB1'));
const pc = popcorn();
pc.position.set(0, 0.76, 0.08);
props.add(pc);
blob(scene, sres, 0, 0.05, 2.6);
}
if (act === 'laptop') {
const bb = new THREE.Mesh(SPH, M('#7B5CFF', 'fabric'));
bb.scale.set(0.75, 0.32, 0.72);
bb.position.y = 0.26;
bb.castShadow = true;
props.add(bb);
blob(scene, sres, 0, 0.05, 1.5);
}
if (act === 'director') {
props.add(directorChair());
blob(scene, sres, 0, 0, 1.3);
}
if (act === 'mic') {
const m = micStand();
m.position.set(0.42, 0, 0.45);
m.rotation.y = -0.4;
props.add(m);
}
let ez = null;
if (act === 'draw') {
ez = easel();
ez.g.position.set(0.7, 0, -0.1);
ez.g.rotation.y = -0.55;
props.add(ez.g);
blob(scene, sres, 0.7, 0, 1.2);
}
const cs = names.map((nm, i) => {
const c = buildChar(P[nm] || P.panda),
x = (i - (n - 1) / 2) * sp;
c.idx = i;
c.root.position.x = x;
c.base = -x * 0.15;
c.act = act;
c.ph = i * 0.37 + Math.random() * 0.3;
scene.add(c.root);
c.pickables.forEach(m => m.userData.ci = i);
c.sitting = ['sofa', 'laptop', 'director'].includes(act);
c.idleExpr = {
think: 'think',
dance: 'happy',
jump: 'happy',
mic: 'happy',
director: 'cheeky',
wave: 'cheeky',
juggle: 'happy',
phone: 'neutral'
}[act] || 'neutral';
setExpr(c, c.idleExpr, 0.01);
if (!c.sitting || act === 'laptop')
c.sh = blob(scene, sres, x, 0.05, 1);
if (act === 'sofa') {
c.root.position.z = 0.02;
c.base = -x * 0.25;
}
if (act === 'laptop') {
c.root.position.y = 0.04;
const lp = laptop();
lp.position.set(0, 0.72, 0.44);
c.rig.add(lp);
}
if (act === 'director') {
c.root.position.y = 0.02;
beret(c);
const cl = clapper();
cl.g.position.set(0, -0.62, 0.12);
cl.g.rotation.set(0, 0, 0.2);
c.arms[1].add(cl.g);
c.clap = cl;
}
if (act === 'draw') {
c.root.position.set(-0.45, 0, 0.2);
c.base = 0;
c.strokes = ez.strokes;
}
if (act === 'mic') {
c.notes = ['#FF5A5F', '#FFC23C', '#2EC4B6', '#7B5CFF'].map(col => {
const nm = noteMesh(col);
scene.add(nm);
return nm;
});
}
if (act === 'juggle')
c.balls = [0xFF5A5F, 0xFFC23C, 0x2EC4B6].map(col => {
const b = new THREE.Mesh(SPH, M('#' + col.toString(16).padStart(6, '0'), 'toy'));
b.scale.setScalar(0.12);
scene.add(b);
return b
});
if (act === 'phone') {
const ph = new THREE.Group();
ph.add(new THREE.Mesh(RB(0.26, 0.42, 0.05, 0.04), M('#FF5A5F', 'toy')));
ph.position.set(0, 1.1, 0.5);
ph.rotation.x = -2.2;
c.rig.add(ph);
}
if (act === 'think')
c.th = [0, 1, 2].map(() => {
const b = new THREE.Mesh(SPH, M('#FFFFFF', 'toy'));
scene.add(b);
return b
});
return c;
});
const cfg = {
juggle: [2.9, 4.6, 2.05],
jump: [n * sp + 0.55, 4.1, 1.75],
think: [2.4, 4.0, 1.8],
sofa: [2.95, 2.95, 1.35],
laptop: [2.2, 3.05, 1.35],
director: [2.2, 3.15, 1.45],
mic: [2.3, 3.3, 1.55],
draw: [2.9, 3.3, 1.55]
}[act] || [n * sp + 0.55, 3.35, 1.48];
Object.assign(s, {
scene,
cam,
cs,
W: cfg[0],
H: cfg[1],
lookY: cfg[2],
picks: cs.flatMap(c => c.pickables)
});
const lines = (el.dataset.lines || '').split('|').filter(Boolean);
el.addEventListener('click', e => {
const r = el.getBoundingClientRect();
nd.set(((e.clientX - r.left) / r.width) * 2 - 1, -((e.clientY - r.top) / r.height) * 2 + 1);
ray.setFromCamera(nd, s.cam);
const h = ray.intersectObjects(s.picks, false);
let c = h.length ? s.cs[h[0].object.userData.ci] : null;
if (!c) {
let best = 1e9;
s.cs.forEach(cc => {
cc.head.getWorldPosition(tmp);
tmp.project(s.cam);
const sx = r.left + (tmp.x + 1) / 2 * r.width;
const d = Math.abs(sx - e.clientX);
if (d < best) {
best = d;
c = cc;
}
});
}
c.react = {
type: pick(REACTS),
t0: performance.now() / 1000
};
emojiBurst(e.clientX, e.clientY);
const ex = pick(CLICK_EXPR);
setExpr(c, ex, 2.6);
c.talkUntil = nowS() + 1.2;
if (ex === 'love')
emojiHearts(e.clientX, e.clientY);
if (s.bub)
s.bub.el.remove();
const cta = Math.random() < 0.2;
const r2 = Math.random();
const txt = cta ? pick(CTA_LINES) : (lines.length && r2 < 0.35 ? pick(lines) : (c.lines && c.lines.length && r2 s.el === el);
if (i >= 0) {
const s = list[i];
if (s.bub)
s.bub.el.remove();
list.splice(i, 1);
}
if (el)
el.__slot = null;
}
window.DI_addSlot = add;
window.DI_removeSlot = remove;
document.querySelectorAll('.char-slot').forEach(add);
const clock = new THREE.Clock(),
vt = Math.tan(THREE.MathUtils.degToRad(15));
let t = 0,
drew = true,
frameN = 0;
(function frame() {
requestAnimationFrame(frame);
const dt = Math.min(0.05, clock.getDelta());
t += dt * (reduce ? 0.5 : 1);
frameN++;
const lb = ROOT.classList.contains('lb-open');
cv.style.zIndex = lb ? '3001' : '50';
const vis = [];
for (const s of list) {
const el = s.el;
if (lb !== !!el.closest('.lb'))
continue;
const rv = el.closest('.reveal');
if (rv && !rv.classList.contains('in'))
continue;
const r = el.getBoundingClientRect();
if (r.width < 4 || r.height < 4 || r.bottom vh || r.right vw)
continue;
vis.push([s, r]);
}
if (!vis.length && !drew)
return;
renderer.setViewport(0, 0, vw, vh);
renderer.setScissor(0, 0, vw, vh);
renderer.clear();
const now = performance.now() / 1000;
for (const [s, r] of vis) {
if (!s.built) {
s.el.dataset.film ? buildFilm(s) : buildChars(s);
s.built = true;
}
const a = r.width / r.height;
if (s.film) {
const lt = (now - s.start) % FILM_D;
if (s.el.dataset.sound === '1' && window.SFX && SFX().live()) {
for (const [ct, name, arg] of s.film.cues) {
if ((s.prevT = ct) || (lt
= s.prevT || ct s.bub.until) {
s.bub.el.classList.remove('show');
const b = s.bub.el;
setTimeout(() => b.remove(), 300);
s.bub = null;
}
else {
s.bub.c.head.getWorldPosition(tmp);
tmp.y += 1.3;
tmp.project(s.cam);
const bx = r.left + (tmp.x + 1) / 2 * r.width,
by = r.top + (1 - tmp.y) / 2 * r.height;
const bw = s.bub.el.offsetWidth / 2 + 8;
s.bub.el.style.left = clamp(bx, bw, vw - bw) + 'px';
s.bub.el.style.top = Math.max(70 + s.bub.el.offsetHeight, by) + 'px';
}
}
}
renderer.setViewport(r.left, vh - r.bottom, r.width, r.height);
renderer.setScissor(r.left, vh - r.bottom, r.width, r.height);
renderer.render(s.scene, s.cam);
}
for (const s of list) {
if (s.bub && !vis.some(v => v[0] === s)) {
s.bub.el.remove();
s.bub = null;
}
}
drew = vis.length > 0;
})();
}
try {
if (webglOK()) {
hero();
card();
slots();
}
} catch (err) {
console.error(err);
document.getElementById('heroStage').classList.add('no-webgl');
}