asdf
This commit is contained in:
parent
b5c0adca22
commit
3be6493f3d
@ -89,13 +89,7 @@ export class ThreeBuilder {
|
|||||||
parent: Object3D,
|
parent: Object3D,
|
||||||
parentComponent?: MsonComponent,
|
parentComponent?: MsonComponent,
|
||||||
) {
|
) {
|
||||||
const offset = new Vector3();
|
|
||||||
if (parentComponent?.pivot) {
|
|
||||||
offset.sub(new Vector3().fromArray(parentComponent.pivot as Vec3));
|
|
||||||
}
|
|
||||||
|
|
||||||
const size = new Vector3().fromArray(component.size as Vec3);
|
const size = new Vector3().fromArray(component.size as Vec3);
|
||||||
const pos = new Vector3().fromArray(component.from as Vec3);
|
|
||||||
|
|
||||||
const dilate = new Vector3();
|
const dilate = new Vector3();
|
||||||
if (component.dilate) {
|
if (component.dilate) {
|
||||||
@ -112,9 +106,18 @@ export class ThreeBuilder {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pos = new Vector3();
|
||||||
|
if (parentComponent?.pivot) {
|
||||||
|
pos.fromArray(parentComponent.pivot as Vec3);
|
||||||
|
}
|
||||||
|
pos.setY(pos.y * -1);
|
||||||
|
|
||||||
|
const offset = new Vector3().fromArray(component.from as Vec3);
|
||||||
const halfOffset = offset.clone().divideScalar(2);
|
const halfOffset = offset.clone().divideScalar(2);
|
||||||
const halfSize = size.clone().divideScalar(2);
|
const halfSize = size.clone().divideScalar(2);
|
||||||
const halfDilation = dilate.clone().divideScalar(2);
|
|
||||||
|
offset.setY(offset.y * -1);
|
||||||
|
const adjustedTranslate = halfSize.clone().add(offset);
|
||||||
|
|
||||||
const geometry = new BoxGeometry(
|
const geometry = new BoxGeometry(
|
||||||
size.x + dilate.x,
|
size.x + dilate.x,
|
||||||
@ -125,7 +128,11 @@ export class ThreeBuilder {
|
|||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
|
|
||||||
geometry.translate(halfOffset.x, halfOffset.y, halfOffset.z);
|
geometry.translate(
|
||||||
|
adjustedTranslate.x,
|
||||||
|
adjustedTranslate.y - size.y,
|
||||||
|
adjustedTranslate.z,
|
||||||
|
);
|
||||||
geometry.rotateX(rotate.x);
|
geometry.rotateX(rotate.x);
|
||||||
geometry.rotateY(rotate.y);
|
geometry.rotateY(rotate.y);
|
||||||
geometry.rotateZ(rotate.z);
|
geometry.rotateZ(rotate.z);
|
||||||
@ -135,7 +142,7 @@ export class ThreeBuilder {
|
|||||||
delete (geometry as any).parameters;
|
delete (geometry as any).parameters;
|
||||||
|
|
||||||
// TODO: apply UVs
|
// TODO: apply UVs
|
||||||
pos.add(halfOffset).add(halfSize);
|
// pos.add(halfOffset).add(halfSize);
|
||||||
|
|
||||||
const mesh = new Mesh(geometry, this.material);
|
const mesh = new Mesh(geometry, this.material);
|
||||||
mesh.name = `${name}__mesh`;
|
mesh.name = `${name}__mesh`;
|
||||||
|
Loading…
Reference in New Issue
Block a user