skip to Main Content

Does Three.JS have a function or capability of AI( Artificial intelligence )? Specifically let’s say a FPS game. I want enemies to look for me and try to kill me, is it possible in three.js? Do they have a functionality or a system of such?



  1. I’m afraid not. Three.js is just a engine for displaying 3d content.

    Login or Signup to reply.
  2. Webgl

    • create buffer
    • bind buffer
    • allocate data
    • set up state
    • issue draw call
    • run GLSL shaders


    • create a 3d context using WebGL
    • create 3 dimensional objects
    • create a scene graph
    • create primitives like spheres, cubes, toruses
    • move objects around, rotate them scale them
    • test for intersections between rays, triangles, planes, spheres, etc.
    • create ‘materials’ (rather than shaders)


    • write algorithms

    I want enemies to look for me and try to kill me

    Yes, three.js is capable of doing this, you just have to write an algorithm using three’s classes. Your enemies would be 3d objects, casting rays, intersecting with other objects, etc.

    You would be building a game engine, and you could use three.js as your rendering framework within that engine. Rendering is just one part of it. Think of a 2d shooter, you could make it using a 2d context, but you could also enhance it and make it 2.5d, by working with a 3d context. Everything else can stay the same.

    any webgl engine that might have it ? or is it just not a webgl thing

    Unity probably has everything you can possibly think of. Unity is capable of outputting WebGL, so it could be considered a ‘webgl engine’.

    Bablyon.js is more engine like.

    Three Js is the best and most powerfull WebGL 3d engine that has no equal on the market , and its missing out on such an ability

    Three.js isn’t exactly a 3d engine. Wikipedia says:

    Three.js is a lightweight cross-browser JavaScript library/API used to
    create and display animated 3D computer graphics on a Web browser.
    Three.js uses WebGL.

    so if i need to just draw a car, or a spinning logo, i don’t need them to come looking for me, or try to shoot me. I just need them to stay in one place, and rotate.

    For a graphics demo you don’t even need this – with a few draw instructions, you could render a full screen quad with a very elaborate pixel shader. Three gives you a ton of options, especially if you consider all the featured examples.

    It works both ways, while you can expand three.js anyway you want, you can strip it down for just a very specific purpose.

    If you need to build an app that needs to do image processing, and feature no ‘3d’ graphics, you could still leverage webgl with three.js.

    You don’t need any vector, matrix, ray , geometry classes.
    If you don’t have vector3, you probably cant keep planeGeometry, but you would use bufferGeometry, and manually construct a plane. No transformations need to happen, so no need for matrix classes. You’d use shaders, and textures, and perhaps something like the EffectsComposer.

    Login or Signup to reply.
  3. Using it to create games only is one possibility. However few websites raise with pre-coded stuff like AI (among other things) to attract game creators, but using them is more restrictive than writing the exact code you need

    Login or Signup to reply.
  4. Three.js itself doesn’t however is a great AI engine that can work in collaboration with three to create AI.

    They do a line if sight and a shooting game logic, as well as car logic which I’ve been playing around with recently, a React Three Fiber example here:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top