refactor: ShapeView owned by physics
This commit is contained in:
parent
077b20a56c
commit
0bb3a05f8d
|
@ -1,7 +1,7 @@
|
|||
import {compose} from '@avocado/core';
|
||||
import {Color, Container, Primitives, ShapeView} from '@avocado/graphics';
|
||||
import {Color, Container, Primitives} from '@avocado/graphics';
|
||||
import {Rectangle, Vector} from '@avocado/math';
|
||||
import {BodyView, shapeFromJSON} from '@avocado/physics';
|
||||
import {BodyView, shapeFromJSON, ShapeView} from '@avocado/physics';
|
||||
|
||||
import {StateProperty, Trait} from '../trait';
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ export {Image} from './image';
|
|||
export {Primitives} from './primitives';
|
||||
export {Renderable} from './renderable';
|
||||
export {Renderer} from './renderer';
|
||||
export {ShapeView} from './shape-view';
|
||||
export {Sprite} from './sprite';
|
||||
|
||||
if (PIXI) {
|
||||
|
|
|
@ -21,13 +21,13 @@ export class BodyView extends Renderable {
|
|||
this.primitives.drawLine(
|
||||
[xMiddle, aabb[1]],
|
||||
[xMiddle, aabb[1] + (aabb[3] - 0.0001)],
|
||||
Primitives.lineStyle(new Color(255, 255, 0), 1)
|
||||
Primitives.lineStyle(new Color(255, 255, 0), 0.5)
|
||||
);
|
||||
const yMiddle = aabb[1] + (aabb[3] / 2);
|
||||
this.primitives.drawLine(
|
||||
[aabb[0], yMiddle],
|
||||
[aabb[0] + (aabb[2] -0.0001), yMiddle],
|
||||
Primitives.lineStyle(new Color(255, 255, 0), 1)
|
||||
Primitives.lineStyle(new Color(255, 255, 0), 0.5)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ export {RectangleShape};
|
|||
import {ShapeList} from './list';
|
||||
export {ShapeList};
|
||||
|
||||
export {ShapeView} from './shape-view';
|
||||
|
||||
export function shapeFromJSON(json) {
|
||||
let shape;
|
||||
switch (json.type) {
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import {ShapeList, PolygonShape} from '@avocado/physics';
|
||||
import {Color, Container, Primitives, Renderable} from '@avocado/graphics';
|
||||
|
||||
import {Color} from './color';
|
||||
import {Container} from './container';
|
||||
import {Primitives} from './primitives';
|
||||
import {Renderable} from './renderable';
|
||||
import {ShapeList} from './list';
|
||||
import {PolygonShape} from './polygon';
|
||||
|
||||
export class ShapeView extends Renderable {
|
||||
|
||||
|
@ -45,7 +43,7 @@ export class ShapeView extends Renderable {
|
|||
primitives.drawLine(
|
||||
lastVertice,
|
||||
vertice,
|
||||
Primitives.lineStyle(new Color(255, 0, 255), 1),
|
||||
Primitives.lineStyle(new Color(255, 0, 255), 0.5),
|
||||
);
|
||||
}
|
||||
lastVertice = vertice;
|
||||
|
@ -53,7 +51,7 @@ export class ShapeView extends Renderable {
|
|||
primitives.drawLine(
|
||||
lastVertice,
|
||||
firstVertice,
|
||||
Primitives.lineStyle(new Color(255, 0, 255), 1),
|
||||
Primitives.lineStyle(new Color(255, 0, 255), 0.5),
|
||||
);
|
||||
this.container.removeAllChildren();
|
||||
this.container.addChild(primitives);
|
Loading…
Reference in New Issue
Block a user