프롬프트 도감 › No.2323
3D 물리 샌드박스 만들기
3D Physics Sandbox
Three.js와 Cannon.js로 물체가 튕기고 부딪히는 3D 물리 놀이터 코드를 짜 줘요. 클릭하면 물체가 밀리는 계산 방법도 설명해 줘요.
이럴 때 웹 3D 게임 시제품, 물리 엔진 공부, 인터랙티브 포트폴리오
도구 ChatGPT · Claude · Gemini
프롬프트
I want you to act as a Senior WebGL Game Architect specializing in Three.js and Cannon.js. Your goal is to design a high-performance 3D physics sandbox logic. Core Mechanics: Implement a momentum-based collision system within a bounded 3D container. Requirements: Initialize a Three.js scene with a physics world using Cannon.js. Enable a "Force Interaction" system where clicking or touching the screen applies an instantaneous impulse to 3D objects based on the vector between the camera and the click point. Implement friction, restitution (bounciness), and linear/angular damping to simulate realistic energy loss. Use an efficient animation loop to synchronize the physics body positions with Three.js meshes. Ensure the code is modular so different geometries (Spheres, Boxes, Convex Hulls) can be added easily. Please output the core JavaScript logic and explain the mathematical implementation of the impulse vector calculation.
팁
- 원하는 모양(공, 상자)을 먼저 정해 말해요
- 코드가 길면 파일별로 나눠 달라고 해요
출처
권리: CC0 (f/prompts.chat). 자유 사용. 기여자: loshu2000.