Repository

js/Mobilizing/renderer/3D/three/shape/3D/primitive/Icosahedron.js

import * as THREE from 'three';
import Mesh from "../../Mesh";
import Transform from "../../../scene/Transform";

export default class Icosahedron extends Mesh {
    /**
    * @param {Object} params Parameters object, given by the constructor.
    * @param {Number} [params.radius=1] the icosahedron radius in world unit
    * @param {Number} [params.detail=0] the icosahedron number of points (tesselation and "roundness")
    *
    * @TODO: cette classe est identique à celle du Octahedron.
    */
    constructor({
        radius = 1,
        detail = 0,
    } = {}) {
        super(...arguments);

        this.radius = radius;
        this.detail = detail;

        this.geometry = new THREE.IcosahedronGeometry(this.radius, this.detail);
        this.geometry.dynamic = true;

        //manage the material according to the passed params, see the attachMaterial method below
        this.attachMaterial(this.material);

        this._mesh = new THREE.Mesh(this.geometry, this.material._material);
        this.transform = new Transform(this);
    }
}