Skip to content

Commit

Permalink
debug mode minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyGura committed May 6, 2024
1 parent 26e34a7 commit 1592e34
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/base/models/body-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface BodyOptions {
interactWithCollisionGroups: CollisionGroup[] | 'all';
}

export type DebugBodySettings = { shape: any } & (
export type DebugBodySettings = { shape: any; ignoreTransform?: boolean } & (
| {
type: 'RIGID_STATIC' | 'TRIGGER';
}
Expand Down
6 changes: 4 additions & 2 deletions packages/pixi/src/components/pixi-physics-debug-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ export class PixiPhysicsDebugView {

public sync() {
for (const [c, m] of this.syncMap.entries()) {
m.graphics.position.set(...Pnt2.spr(c.position));
m.graphics.rotation = c.rotation;
const debugSettings: DebugBody2DSettings = c.debugBodySettings;
if (!debugSettings.ignoreTransform) {
m.graphics.position.set(...Pnt2.spr(c.position));
m.graphics.rotation = c.rotation;
}
let color = 0xffffff;
switch (debugSettings.type) {
case 'RIGID_DYNAMIC':
Expand Down
8 changes: 5 additions & 3 deletions packages/three/src/components/three-physics-debug-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ export class ThreePhysicsDebugView {

public render(nativeRenderer: WebGLRenderer, nativeCamera: Camera) {
for (const [c, m] of this.syncMap.entries()) {
m.position.set(...Pnt3.spr(c.position));
m.quaternion.set(...Qtrn.spr(c.rotation));
const debugSettings: DebugBody3DSettings = c.debugBodySettings;
if (!debugSettings.ignoreTransform) {
m.position.set(...Pnt3.spr(c.position));
m.quaternion.set(...Qtrn.spr(c.rotation));
}
if (m.material) {
const debugSettings: DebugBody3DSettings = c.debugBodySettings;
let color = 0xffffff;
switch (debugSettings.type) {
case 'RIGID_DYNAMIC':
Expand Down
13 changes: 13 additions & 0 deletions packages/three/src/three-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@gg-web-engine/core';
import {
BoxGeometry,
BufferGeometry,
CapsuleGeometry,
ConeGeometry,
CylinderGeometry,
Expand All @@ -21,6 +22,7 @@ import {
PlaneGeometry,
SphereGeometry,
Texture,
Vector3,
} from 'three';
import { ThreeDisplayObjectComponent } from './components/three-display-object.component';
import { ThreeVisualTypeDocRepo } from './types';
Expand Down Expand Up @@ -142,6 +144,17 @@ export class ThreeFactory extends IDisplayObject3dComponentFactory<ThreeVisualTy
mesh.add(submesh);
}
break;
case 'MESH':
const geometry = new BufferGeometry();
geometry.setFromPoints(descriptor.vertices.map(x => new Vector3(...Pnt3.spr(x))));
geometry.setIndex(
descriptor.faces.reduce((p, c) => {
p.push(...c);
return p;
}, [] as number[]),
);
mesh = new Mesh(geometry, threeMat);
break;
}
if (!mesh) {
throw new Error(`Primitive with shape "${descriptor.shape}" not implemented`);
Expand Down

0 comments on commit 1592e34

Please sign in to comment.