Source Academy Modules
    Preparing search index...

    Function createCuboid

    • Creates a cuboid. joel-todo: The dynamic version wont work

      This function is used to create the floor and wall controllers.

      The returned Cuboid object is designed to be added to the world using addControllerToWorld.

      This is a Controller function and should be called within init_simulation.

      Parameters

      • physics: Physics

        The physics engine passed to the world

      • renderer: Renderer

        The renderer engine of the world. See createRenderer

      • position_x: number

        The x position of the cuboid

      • position_y: number

        The y position of the cuboid

      • position_z: number

        The z position of the cuboid

      • width: number

        The width of the cuboid in meters

      • length: number

        The length of the cuboid in meters

      • height: number

        The height of the cuboid in meters

      • mass: number

        The mass of the cuboid in kg

      • color: string | number

        The color of the cuboid. Can be a hex code or a string. {@see https://threejs.org/docs/#api/en/math/Color}

      • bodyType: string

        "rigid" or "dynamic". Determines if the cuboid is fixed or can move.

      Returns Cuboid

      Cuboid

      init_simulation(() => {
      const physics = createPhysics();
      const renderer = createRenderer();
      const timer = createTimer();
      const robot_console = createRobotConsole();
      const world = createWorld(physics, renderer, timer, robot_console);

      const cuboid = createCuboid(...);
      addControllerToWorld(cuboid, world);

      return world;
      });