Improve docs

This commit is contained in:
Alexander Buzin 2017-07-02 15:29:21 +03:00
parent 62f5badb17
commit bd0ebf227d
23 changed files with 213 additions and 1 deletions

View File

@ -76,6 +76,13 @@ class Box extends MeshComponent {
super(params, Box.defaults, Box.instructions);
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Box
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -72,6 +72,13 @@ class Circle extends MeshComponent {
super(params, Circle.defaults, Circle.instructions);
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Circle
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -103,6 +103,13 @@ class Cone extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Cone
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -106,6 +106,13 @@ class Cylinder extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Cylinder
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -76,6 +76,13 @@ class Dodecahedron extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Dodecahedron
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -101,6 +101,13 @@ class Extrude extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Extrude
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -72,6 +72,13 @@ class Icosahedron extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Icosahedron
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -5,7 +5,47 @@ import {
import {MeshComponent} from '../../core/MeshComponent';
/**
* @class Importer
* @category components/meshes
* @description Importer is a loader for meshes and any other data to your scene
* @param {Object} [params] - The params.
* @extends module:core.MeshComponent
* @memberof module:components/meshes
* @example <caption>Creating a Importer, and adding to app</caption>
* new Importer({
* loader: new THREE.OBJLoader(),
*
* parse(geometry, material) { // data from loader
* return new THREE.Mesh(geometry, material); // should return your .native (mesh in this case)
* },
*
* position: [0, 100, 0]
* }).addTo(app);
*/
class Importer extends MeshComponent {
/**
* Default values for parameters
* @member {Object} module:components/meshes.Importer#defaults
* @static
* @default <pre>
* {
* url: '',
* loader: new JSONLoader(),
*
* onLoad() {},
* onProgress() {},
* onError() {},
*
* texturePath: null,
* useCustomMaterial: false,
*
* parser(geometry, materials) {
* return new Mesh(geometry, materials);
* }
* }</pre>
*/
static defaults = {
...MeshComponent.defaults,
@ -28,6 +68,25 @@ class Importer extends MeshComponent {
...MeshComponent.instructions
};
/**
* @method filter
* @description Default values for parameters
* @static
* @param {THREE.Mesh} object Instance for iterating through it's children.
* @param {Function} filter Function with child as argument, should return a boolean whether include the child or not.
* @return {THREE.Mesh} object with children
* @memberof module:components/meshes.Importer
* @example <caption>Removing unnecessary lights from children</caption>
* new Icosahedron({
* loader: new THREE.OBJLoader(),
*
* parse(group) { // data from loader
* return Importer.filter(group, child => !child.isLight); // remove lights
* },
*
* position: [0, 100, 0]
* }).addTo(app);
*/
static filter(object, filter) {
const processFilter = object => {
object.children.forEach((el, index) => {
@ -45,6 +104,13 @@ class Importer extends MeshComponent {
super(params, Importer.defaults, Importer.instructions, false);
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Importer
*/
build(params = {}) {
const promise = new Promise(resolve => {
if (params.texturePath) params.laoder.setTexturePath(params.texturePath);

View File

@ -87,6 +87,13 @@ class Lathe extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Lathe
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -67,6 +67,13 @@ class Line extends MeshComponent {
super(params, Line.defaults, Line.instructions);
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Line
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -63,6 +63,13 @@ class Octahedron extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Octahedron
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -69,6 +69,13 @@ class Parametric extends MeshComponent {
super(params, Parametric.defaults, Parametric.instructions);
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Parametric
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -77,6 +77,13 @@ class Plane extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Plane
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -110,6 +110,13 @@ class Polyhedron extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Polyhedron
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -102,6 +102,13 @@ class Ring extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Ring
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -82,6 +82,13 @@ class Shape extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Shape
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -77,6 +77,13 @@ class Sphere extends MeshComponent {
super(params, Sphere.defaults, Sphere.instructions);
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Sphere
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -81,6 +81,13 @@ class Tetrahedron extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Tetrahedron
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -107,6 +107,13 @@ class Text extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Text
*/
build(params = {}) {
const promise = new Promise(resolve => {
FontLoader.load(params.geometry.parameters.font, font => {

View File

@ -94,6 +94,13 @@ class Torus extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Torus
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -99,6 +99,13 @@ class Torusknot extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Torusknot
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -108,6 +108,13 @@ class Tube extends MeshComponent {
}
}
/**
* @method build
* @description Build livecycle creates a mesh using input params.
* @param {Object} params Component parameters.
* @return {THREE.Mesh} Built mesh
* @memberof module:components/meshes.Tube
*/
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),

View File

@ -120,7 +120,6 @@ class MeshComponent extends Component {
/**
* @method build
* @instance
* @description Build livecycle should return a native object.
* @throws {CompositionError}
* @memberof module:core.MeshComponent