gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
с помощью three.js хочу через несколько точек построить белую линию, по которой будет…
- User
с помощью three.js хочу через несколько точек построить белую линию, по которой будет пробегать красная полоса
- Assistant
Вот пример кода, который поможет вам построить белую линию с пробегающей по ней красной полосой с использованием three.js:
// Создание сцены, камеры и рендерера 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); document.body.appendChild(renderer.domElement); // Параметры материала линии const lineMaterial = new THREE.LineBasicMaterial({ color: 0xffffff }); // Создание точек для линии const points = []; points.push(new THREE.Vector3(-10, 0, 0)); points.push(new THREE.Vector3(0, 10, 0)); points.push(new THREE.Vector3(10, 0, 0)); // Создание линии const lineGeometry = new THREE.BufferGeometry().setFromPoints(points); const line = new THREE.Line(lineGeometry, lineMaterial); scene.add(line); // Параметры материала полосы const stripeMaterial = new THREE.MeshBasicMaterial({ color: 0xff0000 }); // Создание полосы const stripeGeometry = new THREE.PlaneGeometry(0.2, 15); const stripe = new THREE.Mesh(stripeGeometry, stripeMaterial); stripe.position.set(0, 5, 0); scene.add(stripe); // Перемещение камеры camera.position.z = 20; // Анимация сцены function animate() { requestAnimationFrame(animate); line.rotation.z += 0.01; // Поворот линии renderer.render(scene, camera); } animate();
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.