• TOP
  • NEWS
  • ABOUT
  • SERVICE
  • WORKS
  • PROJECT
  • BLOG
  • CONTACT
taziku
  • TOP
  • NEWS
  • ABOUT
  • SERVICE
  • WORKS
  • PROJECT
  • BLOG
  • CONTACT

Claude 3 で書くクリエイティブコーディング

2024年3月25日
AI BLOG Technology
Claude 生成AI

非常に精度が高い、Claude 3、その精度は日本語だけで無く、プログラミングの側面でもかなりの精度を誇っています。今回はClaude 3を活用することで、より直感的かつクリエイティブなアプローチのコーディングを自然言語で行うことが可能です。

今回はThree.jsを指定した上でコーディングに挑戦してみました。

生成したプログラム

今回は立方体のキューブが空間を飛び交いつつ、マウスの位置によって立方体の色を変えるというアニメーションを自然言語でClaude 3に依頼。Claude 3は、シンプルな自然言語で内容を理解し、対応するコードを自動的に生成します。

実際のコード

<!DOCTYPE html>
<html>
<head>
  <title>Creative Animation with Three.js</title>
  <style>
    body { margin: 0; }
    canvas { width: 100%; height: 100%; }
  </style>
</head>
<body>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
  <script>
    // シーンの作成
    const scene = new THREE.Scene();

    // カメラの設定
    const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
    camera.position.z = 5;

    // レンダラーの設定
    const renderer = new THREE.WebGLRenderer();
    renderer.setSize(window.innerWidth, window.innerHeight);
    document.body.appendChild(renderer.domElement);

    // 立方体の作成
    const geometry = new THREE.BoxGeometry(1, 1, 1);
    const cubes = [];

    for (let i = 0; i < 50; i++) {
      const materials = [
        new THREE.MeshBasicMaterial({ color: 0xff0000, transparent: true, opacity: 0.8 }),
        new THREE.MeshBasicMaterial({ color: 0x00ff00, transparent: true, opacity: 0.6 }),
        new THREE.MeshBasicMaterial({ color: 0x0000ff, transparent: true, opacity: 0.4 }),
        new THREE.MeshBasicMaterial({ color: 0xffff00, transparent: true, opacity: 0.6 }),
        new THREE.MeshBasicMaterial({ color: 0xff00ff, transparent: true, opacity: 0.8 }),
        new THREE.MeshBasicMaterial({ color: 0x00ffff, transparent: true, opacity: 1.0 })
      ];
      const cube = new THREE.Mesh(geometry, materials);
      cube.position.x = Math.random() * 10 - 5;
      cube.position.y = Math.random() * 10 - 5;
      cube.position.z = Math.random() * 10 - 5;
      scene.add(cube);
      cubes.push(cube);
    }

    // 境界線の作成
    const edgesMaterial = new THREE.LineBasicMaterial({ color: 0xffffff });
    cubes.forEach((cube) => {
      const edges = new THREE.EdgesGeometry(cube.geometry);
      const line = new THREE.LineSegments(edges, edgesMaterial);
      cube.add(line);
    });

    // アニメーションループ
    function animate() {
      requestAnimationFrame(animate);

      cubes.forEach((cube, index) => {
        cube.rotation.x += 0.01;
        cube.rotation.y += 0.01;
        cube.position.y = Math.sin(Date.now() * 0.001 + index * 0.1) * 2;
      });

      renderer.render(scene, camera);
    }

    // マウスムーブイベントの処理
    document.addEventListener('mousemove', onDocumentMouseMove, false);

    function onDocumentMouseMove(event) {
      const mouseX = (event.clientX / window.innerWidth) * 2 - 1;
      const mouseY = -(event.clientY / window.innerHeight) * 2 + 1;

      cubes.forEach((cube) => {
        const distance = Math.sqrt(Math.pow(mouseX - cube.position.x, 2) + Math.pow(mouseY - cube.position.y, 2));
        const hue = Math.floor(distance * 100) % 360;
        cube.material.forEach((material) => {
          material.color.setHSL(hue / 360, 1, 0.5);
        });
      });
    }

    // ウィンドウリサイズ時の処理
    window.addEventListener('resize', onWindowResize, false);

    function onWindowResize() {
      camera.aspect = window.innerWidth / window.innerHeight;
      camera.updateProjectionMatrix();
      renderer.setSize(window.innerWidth, window.innerHeight);
    }

    // アニメーションの開始
    animate();
  </script>
</body>
</html>

動作デモ

実際の動作については以下をご覧ください。

以下のURLは上記からの修正版-境界線を引き、各面を透明度を変更するように修正
https://taziku.co.jp/c-coding/c-anime01.html

クリエイターもコーディングが可能に

クリエイターがビジョンを言葉で表現すれば、Claude 3がそれを視覚的に表現するためのコードを生成してくれます。プログラミングスキルを持たないクリエイターでも、インタラクティブなデジタルアートを創作することが可能になる世界がすぐそこまで来ています。

※当サイトに掲載されている商標、一部画像、スクリ-ンショット、文章に置いては著作権侵害を目的に利用しておらず、第三十二条で定められる引用の範囲で使用しています。万が一問題があれば、お問い合わせからご連絡ください。即刻削除いたします。また、本ブログは業務の研究開発のためのものとなり、一部、弊社に関連性が無いものも掲載しております。

AIの最新情報を随時発信中

Xやnoteでは、AI・生成AI・LLMなどの最新情報や、ChatGPTやMidjourneyのプロンプトテクニックを連載中!フォローよろしくお願いします。

生成AI・AIの導入・研修・DXの支援はtazikuへ

生成AI・LLMなど、AIを活用したAIの導入・DXコンサルティング、AI領域の研修・講演などのご相談はお気軽にお問い合わせフォーム、もしくは生成AIソリューションAI CREATIVE BASEから、ご相談・お問い合せください。

PREV Claude 3 OpusのVisionでOCRを試す
NEXT Claude 3 で画像連携のクリエイティブコーディング
Related Post
ChatGPT×コードエディタ「Cursor」の料金体系
背景を切り抜くStable Diffusion拡張機能「RemBG」
AIを活用した「ジェネーティブ塗りつぶし」アウトペイントを試す
アニメーションを生成できるAnimateDiffをインストール
新verのMidJourneyを使ってテクノロジー企業の展示会ブースを創る
ChatGPTプラグイン「Zapier」- 様々なアプリケーションを連携してタスクを実行
Related Post
進化するMidjourney v7が描く次世代のAI画像生成
Claude 3.5の新機能 新モデル登場とPC操作機能
Claude 3 の連鎖プロンプト「プロンプトチェーン」を試す
Claude 3 で画像をピクセル化するプログラムを生成
Claude 3で登場人物の会話を生成する
Claude 3 でXMLタグを利用する

« PREV

Back to list

NEXT »

  • 投稿検索

  • ABOUT US?

    tazikuは東京・名古屋を拠点に活動するクリエイティブスタジオです。
    AI・生成AI・LLMとクリエイティブを掛け合わせ、新しいクリエイティブを提供します。
    Works
    Service
    Contact
  • AI CREATIVE BASE

    デザイン、ビジュアル、音声、空間演出。生成AIでクリエイティブワークフローに革新を与え、ビジネスの成果を最大化します。

    詳細を見る

  • MENU

    • BLOG
      • Think
      • Creative
      • Technology
        • AI
        • メタバース
    • Project
      • AIアニメプロジェクト
      • どうくつたんけん
  • NEW POST

    • 進化するMidjourney v7が描く次世代のAI画像生成
    • Claude 3.5の新機能 新モデル登場とPC操作機能
    • Claude 3 の連鎖プロンプト「プロンプトチェーン」を試す
    • Claude 3 で画像をピクセル化するプログラムを生成
    • Claude 3で登場人物の会話を生成する
© 2021 taziku / 株式会社タジク Based in Tokyo and Nagoya | プライバシーポリシー