mirror of
https://github.com/WhitestormJS/whs.js.git
synced 2026-02-01 16:57:32 +00:00
Improve docs
This commit is contained in:
parent
62f5badb17
commit
bd0ebf227d
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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 => {
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user