UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

37 lines (36 loc) 1.25 kB
"use strict"; import { BaseSopOperation } from "./_Base"; import { Vector3 } from "three"; import { IcosahedronBufferGeometry } from "../../../core/geometry/operation/Icosahedron"; import { ObjectType } from "../../../core/geometry/Constant"; import { isBooleanTrue } from "../../../core/BooleanValue"; export class IcosahedronSopOperation extends BaseSopOperation { static type() { return "icosahedron"; } cook(input_contents, params) { const object = this._createIcosahedronObject(params); if (this._node) { object.name = this._node.name(); } return this.createCoreGroupFromObjects([object]); } _createIcosahedronObject(params) { const pointsOnly = isBooleanTrue(params.pointsOnly); const geometry = new IcosahedronBufferGeometry(params.radius, params.detail, pointsOnly); geometry.translate(params.center.x, params.center.y, params.center.z); if (pointsOnly) { const object = this.createObject(geometry, ObjectType.POINTS); return object; } else { geometry.computeVertexNormals(); return this.createObject(geometry, ObjectType.MESH); } } } IcosahedronSopOperation.DEFAULT_PARAMS = { radius: 1, detail: 0, pointsOnly: false, center: new Vector3(0, 0, 0) };