diff --git a/packages/core/src/base/models/body-options.ts b/packages/core/src/base/models/body-options.ts index e02ce80..3e8451d 100644 --- a/packages/core/src/base/models/body-options.ts +++ b/packages/core/src/base/models/body-options.ts @@ -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'; } diff --git a/packages/pixi/src/components/pixi-physics-debug-view.ts b/packages/pixi/src/components/pixi-physics-debug-view.ts index 0c1f7dd..bc5a2a1 100644 --- a/packages/pixi/src/components/pixi-physics-debug-view.ts +++ b/packages/pixi/src/components/pixi-physics-debug-view.ts @@ -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': diff --git a/packages/three/src/components/three-physics-debug-view.ts b/packages/three/src/components/three-physics-debug-view.ts index 24254d1..f8f013d 100644 --- a/packages/three/src/components/three-physics-debug-view.ts +++ b/packages/three/src/components/three-physics-debug-view.ts @@ -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': diff --git a/packages/three/src/three-factory.ts b/packages/three/src/three-factory.ts index a6a7e3c..98e567c 100644 --- a/packages/three/src/three-factory.ts +++ b/packages/three/src/three-factory.ts @@ -7,6 +7,7 @@ import { } from '@gg-web-engine/core'; import { BoxGeometry, + BufferGeometry, CapsuleGeometry, ConeGeometry, CylinderGeometry, @@ -21,6 +22,7 @@ import { PlaneGeometry, SphereGeometry, Texture, + Vector3, } from 'three'; import { ThreeDisplayObjectComponent } from './components/three-display-object.component'; import { ThreeVisualTypeDocRepo } from './types'; @@ -142,6 +144,17 @@ export class ThreeFactory extends IDisplayObject3dComponentFactory 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`);