mirror of
https://github.com/WhitestormJS/whs.js.git
synced 2026-02-01 16:57:32 +00:00
Fix existing meshes
This commit is contained in:
parent
015b47e385
commit
4605eeddae
@ -86,9 +86,7 @@ class Box extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer ? BoxBufferGeometry : BoxGeometry;
|
||||
|
||||
const geometry = new GConstruct(
|
||||
const geometry = new (params.buffer ? BoxBufferGeometry : BoxGeometry)(
|
||||
params.geometry.width,
|
||||
params.geometry.height,
|
||||
params.geometry.depth,
|
||||
|
||||
@ -116,9 +116,7 @@ class Cylinder extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer && !params.softbody ? CylinderBufferGeometry : CylinderGeometry;
|
||||
|
||||
const geometry = new GConstruct(
|
||||
const geometry = new (params.buffer ? CylinderBufferGeometry : CylinderGeometry)(
|
||||
params.geometry.radiusTop,
|
||||
params.geometry.radiusBottom,
|
||||
params.geometry.height,
|
||||
@ -129,8 +127,6 @@ class Cylinder extends MeshComponent {
|
||||
params.geometry.thetaLength
|
||||
);
|
||||
|
||||
if (params.softbody) this.proccessSoftbodyGeometry(geometry);
|
||||
|
||||
return geometry;
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,9 +86,7 @@ class Dodecahedron extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer && !params.softbody ? DodecahedronBufferGeometry : DodecahedronGeometry;
|
||||
|
||||
return new GConstruct(
|
||||
return new (params.buffer ? DodecahedronBufferGeometry : DodecahedronGeometry)(
|
||||
params.geometry.radius,
|
||||
params.geometry.detail
|
||||
);
|
||||
|
||||
@ -111,12 +111,12 @@ class Extrude extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const extrudeGeometry = new ExtrudeGeometry(
|
||||
const geometry = new ExtrudeGeometry(
|
||||
params.geometry.shapes,
|
||||
params.geometry.options
|
||||
);
|
||||
|
||||
return params.buffer ? new BufferGeometry().fromGeometry(extrudeGeometry) : extrudeGeometry;
|
||||
return params.buffer ? new BufferGeometry().fromGeometry(geometry) : geometry;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -82,9 +82,7 @@ class Icosahedron extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer && !params.softbody ? IcosahedronBufferGeometry : IcosahedronGeometry;
|
||||
|
||||
return new GConstruct(
|
||||
return new (params.buffer ? IcosahedronBufferGeometry : IcosahedronGeometry)(
|
||||
params.geometry.radius,
|
||||
params.geometry.detail
|
||||
);
|
||||
|
||||
@ -97,9 +97,7 @@ class Lathe extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer && !params.softbody ? LatheBufferGeometry : LatheGeometry;
|
||||
|
||||
return new GConstruct(
|
||||
return new (params.buffer ? LatheBufferGeometry : LatheGeometry)(
|
||||
params.geometry.points
|
||||
);
|
||||
}
|
||||
|
||||
@ -2,8 +2,7 @@ import {
|
||||
Line as LineNative,
|
||||
BufferGeometry,
|
||||
Geometry,
|
||||
BufferAttribute,
|
||||
Vector3
|
||||
BufferAttribute
|
||||
} from 'three';
|
||||
|
||||
import {MeshComponent} from '../../core/MeshComponent';
|
||||
@ -35,9 +34,7 @@ class Line extends MeshComponent {
|
||||
* {
|
||||
* geometry: {
|
||||
* curve: false,
|
||||
* points: 50,
|
||||
* start: new Vector3(0, 0, 0),
|
||||
* end: new Vector3(10, 0, 0)
|
||||
* points: 50
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
@ -46,9 +43,7 @@ class Line extends MeshComponent {
|
||||
...MeshComponent.defaults,
|
||||
geometry: {
|
||||
curve: false,
|
||||
points: 50,
|
||||
start: new Vector3(0, 0, 0),
|
||||
end: new Vector3(10, 0, 0)
|
||||
points: 50
|
||||
}
|
||||
};
|
||||
|
||||
@ -82,13 +77,6 @@ class Line extends MeshComponent {
|
||||
buildGeometry(params = {}) {
|
||||
const geometry = params.buffer ? new BufferGeometry() : new Geometry();
|
||||
|
||||
if (params.geometry.curve === false) {
|
||||
geometry.vertices.push(params.geometry.start);
|
||||
geometry.vertices.push(params.geometry.end);
|
||||
|
||||
return geometry;
|
||||
}
|
||||
|
||||
if (params.buffer) {
|
||||
const pp = params.geometry.curve.getPoints(params.geometry.points);
|
||||
const verts = new Float32Array(pp.length * 3);
|
||||
|
||||
@ -73,9 +73,7 @@ class Octahedron extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer && !params.softbody ? OctahedronBufferGeometry : OctahedronGeometry;
|
||||
|
||||
return new GConstruct(
|
||||
return new (params.buffer ? OctahedronBufferGeometry : OctahedronGeometry)(
|
||||
params.geometry.radius,
|
||||
params.geometry.detail
|
||||
);
|
||||
|
||||
@ -79,9 +79,7 @@ class Parametric extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer && !params.softbody ? ParametricBufferGeometry : ParametricGeometry;
|
||||
|
||||
return new GConstruct(
|
||||
return new (params.buffer ? ParametricBufferGeometry : ParametricGeometry)(
|
||||
params.geometry.func,
|
||||
params.geometry.slices,
|
||||
params.geometry.stacks
|
||||
|
||||
@ -87,17 +87,13 @@ class Plane extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer || params.softbody ? PlaneBufferGeometry : PlaneGeometry;
|
||||
|
||||
const geometry = new GConstruct(
|
||||
const geometry = new (params.buffer ? PlaneBufferGeometry : PlaneGeometry)(
|
||||
params.geometry.width,
|
||||
params.geometry.height,
|
||||
params.geometry.wSegments,
|
||||
params.geometry.hSegments
|
||||
);
|
||||
|
||||
if (params.softbody) this.proccessSoftbodyGeometry(geometry);
|
||||
|
||||
return geometry;
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,9 +120,7 @@ class Polyhedron extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer ? PolyhedronBufferGeometry : PolyhedronGeometry;
|
||||
|
||||
return new GConstruct(
|
||||
return new (params.buffer ? PolyhedronBufferGeometry : PolyhedronGeometry)(
|
||||
params.geometry.verticesOfCube,
|
||||
params.geometry.indicesOfFaces,
|
||||
params.geometry.radius,
|
||||
|
||||
@ -112,9 +112,7 @@ class Ring extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer ? RingBufferGeometry : RingGeometry;
|
||||
|
||||
return new GConstruct(
|
||||
return new (params.buffer ? RingBufferGeometry : RingGeometry)(
|
||||
params.geometry.innerRadius,
|
||||
params.geometry.outerRadius,
|
||||
params.geometry.thetaSegments,
|
||||
|
||||
@ -92,9 +92,7 @@ class Shape extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer ? ShapeBufferGeometry : ShapeGeometry;
|
||||
|
||||
return new GConstruct(
|
||||
return new (params.buffer ? ShapeBufferGeometry : ShapeGeometry)(
|
||||
params.geometry.shapes
|
||||
);
|
||||
}
|
||||
|
||||
@ -87,9 +87,7 @@ class Sphere extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer ? SphereBufferGeometry : SphereGeometry;
|
||||
|
||||
const geometry = new GConstruct(
|
||||
const geometry = new (params.buffer ? SphereBufferGeometry : SphereGeometry)(
|
||||
params.geometry.radius,
|
||||
params.geometry.widthSegments,
|
||||
params.geometry.heightSegments
|
||||
|
||||
@ -91,9 +91,7 @@ class Tetrahedron extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer ? TetrahedronBufferGeometry : TetrahedronGeometry;
|
||||
|
||||
return new GConstruct(
|
||||
return new (params.buffer ? TetrahedronBufferGeometry : TetrahedronGeometry)(
|
||||
params.geometry.radius,
|
||||
params.geometry.detail
|
||||
);
|
||||
|
||||
@ -108,7 +108,7 @@ class Text extends MeshComponent {
|
||||
}
|
||||
|
||||
build(params = {}) {
|
||||
const promise = new Promise((resolve) => {
|
||||
const promise = new Promise(resolve => {
|
||||
FontLoader.load(params.geometry.parameters.font, font => {
|
||||
params.geometry.parameters.font = font;
|
||||
|
||||
@ -117,6 +117,7 @@ class Text extends MeshComponent {
|
||||
params.geometry.text,
|
||||
params.geometry.parameters
|
||||
),
|
||||
|
||||
material: params.material
|
||||
});
|
||||
|
||||
|
||||
@ -118,9 +118,7 @@ class Tube extends MeshComponent {
|
||||
}
|
||||
|
||||
buildGeometry(params = {}) {
|
||||
const GConstruct = params.buffer ? TubeBufferGeometry : TubeGeometry;
|
||||
|
||||
const geometry = new GConstruct(
|
||||
const geometry = new (params.buffer ? TubeBufferGeometry : TubeGeometry)(
|
||||
params.geometry.path,
|
||||
params.geometry.segments,
|
||||
params.geometry.radius,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user