DeepSeek ArtifactsDeepSeek Artifacts

用Three JS打造明代风格3D网页

4.0
en
Technology
Three JS
3D Modeling
Ming Dynasty Architecture
Interactive NPCs
Web Development

النص التوجيهي

I want three JS technology to create a web page, create an immersive 3D environment web page, where the entire drawing constitutes the design of the scene. The scene design should conform to the architectural style of the Ming Dynasty. For example, the ancient city gate of Nanjing, like the ceiling, can be used as a major landmark, and this can be inserted into the 3D modeling, but the 3D modeling requires fine, detailed, reliable, and not just rough modeling, and reflects the characteristics of the Ming Dynasty architecture, corneaves and corners, blue bricks and gray tiles. We also want to add some NPCS as appropriate. Moreover, I hope to use three JS technology to create a character model, that is, a character model controlled by the viewer himself, which can interact with various NPCS, scenes and parts of the environment. Our theme is a variety of projects in Tiangong Open objects, showing the process of various ancient skills, and we hope to carry out the task through NNPC interaction. For example, according to the first item, let's say we work with a blacksmith, we need to go through the task, such as finding ore identification, go to the blacksmith's table for blast furnace control and quenching, and then deliver the finished product to the blacksmith. This triggers a series of tasks. Other aspects can be appropriately added to make the performance more specific and complete

النتيجة المولدة

import React, { useRef, useEffect } from 'react';
import * as THREE from 'three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';

const App = () => {
  const mountRef = useRef(null);

  useEffect(() => {
    const scene = new THREE.Scene();
    const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
    const renderer = new THREE.WebGLRenderer({ antialias: true });
    renderer.setSize(window.innerWidth, window.innerHeight);
    mountRef.current.appendChild(renderer.domElement);

    const controls = new OrbitControls(camera, renderer.domElement);
    controls.enableDamping = true;

    const loader = new GLTFLoader();
    loader.load('https://placehold.co/300X300', (gltf) => {
      scene.add(gltf.scene);
    });

    const ambientLight = new THREE.AmbientLight(0x404040);
    scene.add(ambientLight);

    const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5);
    scene.add(directionalLight);

    camera.position.z = 5;

    const animate = () => {
      requestAnimationFrame(animate);
      controls.update();
      renderer.render(scene, camera);
    };
    animate();

    return () => mountRef.current.removeChild(renderer.domElement);
  }, []);

  return (
    <div ref={mountRef} className='w-screen h-screen bg-gray-900'>
      <div className='absolute top-0 left-0 p-4 text-white'>
        <h1 className='text-4xl font-bold'>Ming Dynasty Scene</h1>
        <p className='mt-2'>Explore the ancient city gate of Nanjing in a fully immersive 3D environment.</p>
      </div>
    </div>
  );
};

export default App;

المزيد من التوصيات

عرض الكل