• Jobs
  • About Us
  • Jobs
    • Home
    • Jobs
    • Courses and challenges
  • Businesses
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

272
Views
Make Image to Particles with Three JS in Next JS

now im learning about Three JS and now im in blocker that my expectation should be like this:

enter image description here

but now my code not shows any view, where my code was like this:

import { useEffect } from "react/cjs/react.development";
import * as THREE from "three";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";

export default () => {
  useEffect(() => {
    const scene = new THREE.Scene();
    const camera = new THREE.PerspectiveCamera(
      75,
      window.innerWidth / window.innerHeight,
      1,
      1000
    );
    const canvas = document.querySelector("canvas.background");
    let renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
    new OrbitControls(camera, renderer.domElement);

    const img = new Image();
    let texture = new THREE.Texture(img);
    img.onload = () => {
      texture.needsUpdate = true;
      const material = new THREE.PointsMaterial({
        size: 20,
        map: texture,
        blending: THREE.AdditiveBlending,
        transparent: true,
        depthTest: false,
      });
      const particle = new THREE.Sprite(material);
      particle.scale.x = particle.scale.y = 1;
      scene.add(particle);
    };
    img.src = "/flower.png";
    scene.add(camera);

    camera.position.z = 3;
    const animate = () => {
      const elapsedTime = new THREE.Clock().getElapsedTime();

      renderer.setPixelRatio(window.devicePixelRatio);
      renderer.setSize(window.innerWidth, window.innerHeight);
      renderer.render(scene, camera);
      requestAnimationFrame(animate);
    };
    animate();
  }, []);

  return <canvas className="background" />;
};

I tried different answers from forum, but seems doesn't works for me

could you guys help? I'll appreciate

over 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can't use THREE.PointsMaterial with THREE.Sprite. THREE.PointsMaterial is intended for THREE.Points. Use THREE.SpriteMaterial instead.

over 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Show me some job opportunities
There's an error!