forked from schteppe/p2.js
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sandbox): remove use of @arancini/systems
- Loading branch information
1 parent
8af103b
commit 5df450b
Showing
37 changed files
with
1,192 additions
and
1,201 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,123 +1,10 @@ | ||
import * as p2 from 'p2-es' | ||
import { Application, Container, FederatedMouseEvent, Graphics } from 'pixi.js' | ||
|
||
export interface SandboxSettings { | ||
physicsStepsPerSecond: number | ||
maxSubSteps: number | ||
paused: boolean | ||
bodyIslandColors: boolean | ||
bodySleepOpacity: boolean | ||
debugPolygons: boolean | ||
drawContacts: boolean | ||
drawAABBs: boolean | ||
renderInterpolatedPositions: boolean | ||
newShapeCollisionGroup?: number | ||
newShapeCollisionMask?: number | ||
enablePanning?: boolean | ||
enableZooming?: boolean | ||
} | ||
|
||
export const defaultSandboxSettings: SandboxSettings = { | ||
physicsStepsPerSecond: 60, | ||
maxSubSteps: 3, | ||
paused: false, | ||
bodyIslandColors: false, | ||
bodySleepOpacity: false, | ||
debugPolygons: false, | ||
drawContacts: false, | ||
drawAABBs: false, | ||
renderInterpolatedPositions: true, | ||
enablePanning: true, | ||
enableZooming: true, | ||
} | ||
|
||
type PointerPositions = { | ||
stagePosition: [number, number] | ||
physicsPosition: [number, number] | ||
} | ||
|
||
type PointerTouches = { | ||
[key: string]: PointerPositions | ||
} | ||
|
||
export type Pointer = { | ||
primaryPointer: PointerPositions | ||
touches: PointerTouches | ||
|
||
pinching: boolean | ||
pinchInitialLength?: number | ||
pinchLength?: number | ||
pinchATouch?: string | ||
pinchBTouch?: string | ||
onPinchStart: Set<() => void> | ||
onPinchMove: Set<() => void> | ||
onPinchEnd: Set<() => void> | ||
|
||
onUp: Set<(e: FederatedMouseEvent) => void> | ||
onDown: Set<(e: FederatedMouseEvent) => void> | ||
onMove: Set<(e: FederatedMouseEvent) => void> | ||
onWheel: Set<(delta: number) => void> | ||
} | ||
|
||
export const createPointer = (): Pointer => { | ||
return { | ||
primaryPointer: { | ||
stagePosition: [0, 0], | ||
physicsPosition: [0, 0], | ||
}, | ||
touches: {}, | ||
pinching: false, | ||
onPinchStart: new Set(), | ||
onPinchMove: new Set(), | ||
onPinchEnd: new Set(), | ||
onUp: new Set(), | ||
onDown: new Set(), | ||
onMove: new Set(), | ||
onWheel: new Set(), | ||
} | ||
} | ||
|
||
export type Sprite = { | ||
graphics: Graphics | ||
drawnSleeping: boolean | null | ||
drawnLineColor: number | null | ||
drawnFillColor: number | null | ||
dirty: boolean | ||
} | ||
|
||
export const createSprite = () => { | ||
return { | ||
graphics: new Graphics(), | ||
drawnSleeping: null, | ||
drawnLineColor: null, | ||
drawnFillColor: null, | ||
dirty: false, | ||
} | ||
} | ||
|
||
export type Pixi = { | ||
canvasElement: HTMLCanvasElement | ||
application: Application | ||
stage: Container | ||
container: Container | ||
background: Graphics | ||
graphics: { | ||
aabb: Graphics | ||
contacts: Graphics | ||
pick: Graphics | ||
drawShape: Graphics | ||
} | ||
onResize: () => void | ||
} | ||
import { Sprite } from '../pixi/sprite' | ||
|
||
export type Entity = { | ||
sandboxSettings?: SandboxSettings | ||
domElement?: HTMLElement | ||
physicsBody?: p2.Body | ||
physicsConstraint?: p2.Constraint | ||
physicsSpring?: p2.Spring | ||
physicsWorld?: p2.World | ||
pixi?: Pixi | ||
pointer?: Pointer | ||
sprite?: Sprite | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
export * from './entity' | ||
export * from './context' | ||
export * from './pointer-system' | ||
export * from './renderer-systems' | ||
export * from './tool-systems' | ||
export * from './utils' | ||
export * from './world' |
Oops, something went wrong.