From a8f925e787e17df0ae5a4727de7fefbd8df7390d Mon Sep 17 00:00:00 2001 From: yyc <395976266@qq.com> Date: Sat, 21 Jan 2017 21:14:25 +0800 Subject: [PATCH 1/7] add cannon,rsvp,wonder-commonlib,wonder-frp dts file --- cannon/index.d.ts | 989 +++++++++++++++++++++++++++++++++ cannon/tsconfig.json | 21 + rsvp/index.d.ts | 315 +++++++++++ rsvp/tsconfig.json | 21 + wonder-commonlib/index.d.ts | 258 +++++++++ wonder-commonlib/tsconfig.json | 21 + wonder-frp/index.d.ts | 718 ++++++++++++++++++++++++ wonder-frp/tsconfig.json | 21 + 8 files changed, 2364 insertions(+) create mode 100644 cannon/index.d.ts create mode 100644 cannon/tsconfig.json create mode 100644 rsvp/index.d.ts create mode 100644 rsvp/tsconfig.json create mode 100644 wonder-commonlib/index.d.ts create mode 100644 wonder-commonlib/tsconfig.json create mode 100644 wonder-frp/index.d.ts create mode 100644 wonder-frp/tsconfig.json diff --git a/cannon/index.d.ts b/cannon/index.d.ts new file mode 100644 index 0000000000..90493d5edd --- /dev/null +++ b/cannon/index.d.ts @@ -0,0 +1,989 @@ +declare module CANNON { + + export interface IAABBOptions { + + upperBound?: Vec3; + lowerBound?: Vec3; + + } + + export class AABB { + + lowerBound: Vec3; + upperBound: Vec3; + + constructor(options?: IAABBOptions); + + setFromPoints(points: Vec3[], position?: Vec3, quaternion?: Quaternion, skinSize?: number): void; + copy(aabb: AABB): void; + extend(aabb: AABB): void; + overlaps(aabb: AABB): boolean; + + } + + export class ArrayCollisionMatrix { + + matrix: Mat3[]; + + get(i: number, j: number): number; + set(i: number, j: number, value?: number): void; + reset(): void; + setNumObjects(n: number): void; + + } + + export class BroadPhase { + + world: World; + useBoundingBoxes: boolean; + dirty: boolean; + + collisionPairs(world: World, p1: Body[], p2: Body[]): void; + needBroadphaseCollision(bodyA: Body, bodyB: Body): boolean; + intersectionTest(bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void; + doBoundingSphereBroadphase(bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void; + doBoundingBoxBroadphase(bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void; + makePairsUnique(pairs1: Body[], pairs2: Body[]): void; + setWorld(world: World): void; + boundingSphereCheck(bodyA: Body, bodyB: Body): boolean; + aabbQuery(world: World, aabb: AABB, result: Body[]): Body[]; + + } + + export class GridBroadphase extends BroadPhase { + + nx: number; + ny: number; + nz: number; + aabbMin: Vec3; + aabbMax: Vec3; + bins: any[]; + + constructor(aabbMin?: Vec3, aabbMax?: Vec3, nx?: number, ny?: number, nz?: number); + + } + + export class NaiveBroadphase extends BroadPhase { + } + + export class ObjectCollisionMatrix { + + matrix: number[]; + + get(i: number, j: number): number; + set(i: number, j: number, value: number): void; + reset(): void; + setNumObjects(n: number): void; + + } + + export class Ray { + + from: Vec3; + to: Vec3; + precision: number; + checkCollisionResponse: boolean; + + constructor(from?: Vec3, to?: Vec3); + + getAABB(result: RaycastResult): void; + + } + + export class RaycastResult { + + rayFromWorld: Vec3; + rayToWorld: Vec3; + hitNormalWorld: Vec3; + hitPointWorld: Vec3; + hasHit: boolean; + shape: Shape; + body: Body; + distance: number; + + reset(): void; + set(rayFromWorld: Vec3, rayToWorld: Vec3, hitNormalWorld: Vec3, hitPointWorld: Vec3, shape: Shape, body: Body, distance: number): void; + + } + + export class SAPBroadphase extends BroadPhase { + + static insertionSortX(a: any[]): any[]; + static insertionSortY(a: any[]): any[]; + static insertionSortZ(a: any[]): any[]; + static checkBounds(bi: Body, bj: Body, axisIndex?: number): boolean; + + axisList: any[]; + world: World; + axisIndex: number; + + constructor(world?: World); + + autoDetectAxis(): void; + aabbQuery(world: World, aabb: AABB, result?: Body[]): Body[]; + + } + + export interface IConstraintOptions { + + collideConnected?: boolean; + wakeUpBodies?: boolean; + + } + + export class Constraint { + + equations: any[]; + bodyA: Body; + bodyB: Body; + id: number; + collideConnected: boolean; + + constructor(bodyA: Body, bodyB: Body, options?: IConstraintOptions); + + update(): void; + + } + + export class DistanceConstraint extends Constraint { + + constructor(bodyA: Body, bodyB: Body, distance: number, maxForce?: number); + + } + + export interface IHingeConstraintOptions { + + pivotA?: Vec3; + axisA?: Vec3; + pivotB?: Vec3; + axisB?: Vec3; + maxForce?: number; + + } + + export class HingeConstraint extends Constraint { + + motorEnabled: boolean; + motorTargetVelocity: number; + motorMinForce: number; + motorMaxForce: number; + motorEquation: RotationalMotorEquation; + + constructor(bodyA: Body, bodyB: Body, options?: IHingeConstraintOptions); + + enableMotor(): void; + disableMotor(): void; + + } + + export class PointToPointConstraint extends Constraint { + + constructor(bodyA: Body, pivotA: Vec3, bodyB: Body, pivotB: Vec3, maxForce?: number); + + } + + + export class LockConstraint extends Constraint { + constructor(bodyA: Body, bodyB: Body, options?:any); + } + + + + export class Equation { + + id: number; + minForce: number; + maxForce: number; + bi: Body; + bj: Body; + a: number; + b: number; + eps: number; + jacobianElementA: JacobianElement; + jacobianElementB: JacobianElement; + enabled: boolean; + + constructor(bi: Body, bj: Body, minForce?: number, maxForce?: number); + + setSpookParams(stiffness: number, relaxation: number, timeStep: number): void; + computeB(a: number, b: number, h: number): number; + computeGq(): number; + computeGW(): number; + computeGWlamda(): number; + computeGiMf(): number; + computeGiMGt(): number; + addToWlamda(deltalambda: number): number; + computeC(): number; + + } + + export class FrictionEquation extends Equation { + + constructor(bi: Body, bj: Body, slipForce: number); + + } + + export class RotationalEquation extends Equation { + + ni: Vec3; + nj: Vec3; + nixnj: Vec3; + njxni: Vec3; + invIi: Mat3; + invIj: Mat3; + relVel: Vec3; + relForce: Vec3; + + constructor(bodyA: Body, bodyB: Body); + + } + + export class RotationalMotorEquation extends Equation { + + axisA: Vec3; + axisB: Vec3; + invLi: Mat3; + invIj: Mat3; + targetVelocity: number; + + constructor(bodyA: Body, bodyB: Body, maxForce?: number); + + } + + export class ContactEquation extends Equation { + + restitution: number; + ri: Vec3; + rj: Vec3; + penetrationVec: Vec3; + ni: Vec3; + rixn: Vec3; + rjxn: Vec3; + invIi: Mat3; + invIj: Mat3; + biInvInertiaTimesRixn: Vec3; + bjInvInertiaTimesRjxn: Vec3; + + constructor(bi: Body, bj: Body); + + } + + export interface IContactMaterialOptions { + + friction?: number; + restitution?: number; + contactEquationStiffness?: number; + contactEquationRelaxation?: number; + frictionEquationStiffness?: number; + frictionEquationRelaxation?: number; + + } + + export class ContactMaterial { + + id: number; + materials: Material[]; + friction: number; + restitution: number; + contactEquationStiffness: number; + contactEquationRelaxation: number; + frictionEquationStiffness: number; + frictionEquationRelaxation: number; + + constructor(m1: Material, m2: Material, options?: IContactMaterialOptions); + + } + + export class Material { + + name: string; + id: number; + friction:number; + restitution:number; + + constructor(name: string); + + } + + export class JacobianElement { + + spatial: Vec3; + rotational: Vec3; + + multiplyElement(element: JacobianElement): number; + multiplyVectors(spacial: Vec3, rotational: Vec3): number; + + } + + export class Mat3 { + + constructor(elements?: number[]); + + identity(): void; + setZero(): void; + setTrace(vec3: Vec3): void; + getTrace(target: Vec3): void; + vmult(v: Vec3, target?: Vec3): Vec3; + smult(s: number): void; + mmult(m: Mat3): Mat3; + scale(v: Vec3, target?: Mat3): Mat3; + solve(b: Vec3, target?: Vec3): Vec3; + e(row: number, column: number, value?: number): number; + copy(source: Mat3): Mat3; + toString(): string; + reverse(target?: Mat3): Mat3; + setRotationFromQuaternion(q: Quaternion): Mat3; + transpose(target?: Mat3): Mat3; + + } + + export class Quaternion { + + x: number; + y: number; + z: number; + w: number; + + constructor(x?: number, y?: number, z?: number, w?: number); + + set(x: number, y: number, z: number, w: number): void; + toString(): string; + toArray(): number[]; + setFromAxisAngle(axis: Vec3, angle: number): void; + toAxisAngle(targetAxis?: Vec3): any[]; + setFromVectors(u: Vec3, v: Vec3): void; + mult(q: Quaternion, target?: Quaternion): Quaternion; + inverse(target?: Quaternion): Quaternion; + conjugate(target?: Quaternion): Quaternion; + normalize(): void; + normalizeFast(): void; + vmult(v: Vec3, target?: Vec3): Vec3; + copy(source: Quaternion): Quaternion; + toEuler(target: Vec3, order?: string): void; + setFromEuler(x: number, y: number, z: number, order?: string): Quaternion; + clone(): Quaternion; + + } + + export class Transform { + + static pointToLocalFrame(position: Vec3, quaternion: Quaternion, worldPoint: Vec3, result?: Vec3): Vec3; + static pointToWorldFrame(position: Vec3, quaternion: Quaternion, localPoint: Vec3, result?: Vec3): Vec3; + + position: Vec3; + quaternion: Quaternion; + + vectorToWorldFrame(localVector: Vec3, result?: Vec3): Vec3; + vectorToLocalFrame(position: Vec3, quaternion: Quaternion, worldVector: Vec3, result?: Vec3): Vec3; + + } + + export class Vec3 { + + static ZERO: Vec3; + + x: number; + y: number; + z: number; + + constructor(x?: number, y?: number, z?: number); + + cross(v: Vec3, target?: Vec3): Vec3; + set(x: number, y: number, z: number): Vec3; + setZero(): void; + vadd(v: Vec3, target?: Vec3): Vec3; + vsub(v: Vec3, target?: Vec3): Vec3; + crossmat(): Mat3; + normalize(): number; + unit(target?: Vec3): Vec3; + norm(): number; + norm2(): number; + distanceTo(p: Vec3): number; + mult(scalar: number, target?: Vec3): Vec3; + scale(scalar: number, target?: Vec3): Vec3; + dot(v: Vec3): number; + isZero(): boolean; + negate(target?: Vec3): Vec3; + tangents(t1: Vec3, t2: Vec3): void; + toString(): string; + toArray(): number[]; + copy(source: Vec3): Vec3; + lerp(v: Vec3, t: number, target?: Vec3): void; + almostEquals(v: Vec3, precision?: number): boolean; + almostZero(precision?: number): boolean; + isAntiparallelTo(v: Vec3, prescision?: number): boolean; + clone(): Vec3; + + } + + export interface IBodyOptions { + position?: Vec3; + velocity?: Vec3; + angularVelocity?: Vec3; + quaternion?: Quaternion; + mass?: number; + material?: number; + type?: number; + linearDamping?: number; + angularDamping?: number; + } + + export class Body extends EventTarget { + + static DYNAMIC: number; + static STATIC: number; + static KINEMATIC: number; + static AWAKE: number; + static SLEEPY: number; + static SLEEPING: number; + static sleepyEvent: IEvent; + static sleepEvent: IEvent; + + id: number; + world: World; + preStep: Function; + postStep: Function; + vlambda: Vec3; + collisionFilterGroup: number; + collisionFilterMask: number; + collisionResponse: boolean; + position: Vec3; + previousPosition: Vec3; + initPosition: Vec3; + velocity: Vec3; + initVelocity: Vec3; + force: Vec3; + mass: number; + invMass: number; + material: Material; + linearDamping: number; + type: number; + allowSleep: boolean; + sleepState: number; + sleepSpeedLimit: number; + sleepTimeLimit: number; + timeLastSleepy: number; + torque: Vec3; + quaternion: Quaternion; + initQuaternion: Quaternion; + angularVelocity: Vec3; + initAngularVelocity: Vec3; + interpolatedPosition: Vec3; + interpolatedQuaternion: Quaternion; + shapes: Shape[]; + shapeOffsets: any[]; + shapeOrentiations: any[]; + inertia: Vec3; + invInertia: Vec3; + invInertiaWorld: Mat3; + invMassSolve: number; + invInertiaSolve: Vec3; + invInteriaWorldSolve: Mat3; + fixedRotation: boolean; + angularDamping: number; + aabb: AABB; + aabbNeedsUpdate: boolean; + wlambda: Vec3; + + constructor(options?: IBodyOptions); + + wakeUp(): void; + sleep(): void; + sleepTick(time: number): void; + updateSolveMassProperties(): void; + pointToLocalFrame(worldPoint: Vec3, result?: Vec3): Vec3; + pointToWorldFrame(localPoint: Vec3, result?: Vec3): Vec3; + vectorToWorldFrame(localVector: Vec3, result?: Vec3): Vec3; + addShape(shape: Shape, offset?: Vec3, orientation?: Quaternion): void; + updateBoundingRadius(): void; + computeAABB(): void; + updateInertiaWorld(force: Vec3): void; + applyForce(force: Vec3, worldPoint: Vec3): void; + applyImpulse(impulse: Vec3, worldPoint: Vec3): void; + updateMassProperties(): void; + getVelocityAtWorldPoint(worldPoint: Vec3, result: Vec3): Vec3; + + } + + export interface IRaycastVehicleOptions { + + chassisBody?: Body; + indexRightAxis?: number; + indexLeftAxis?: number; + indexUpAxis?: number; + + } + + export interface IWheelInfoOptions { + + chassisConnectionPointLocal?: Vec3; + chassisConnectionPointWorld?: Vec3; + directionLocal?: Vec3; + directionWorld?: Vec3; + axleLocal?: Vec3; + axleWorld?: Vec3; + suspensionRestLength?: number; + suspensionMaxLength?: number; + radius?: number; + suspensionStiffness?: number; + dampingCompression?: number; + dampingRelaxation?: number; + frictionSlip?: number; + steering?: number; + rotation?: number; + deltaRotation?: number; + rollInfluence?: number; + maxSuspensionForce?: number; + isFronmtWheel?: boolean; + clippedInvContactDotSuspension?: number; + suspensionRelativeVelocity?: number; + suspensionForce?: number; + skidInfo?: number; + suspensionLength?: number; + maxSuspensionTravel?: number; + useCustomSlidingRotationalSpeed?: boolean; + customSlidingRotationalSpeed?: number; + + position?: Vec3; + direction?: Vec3; + axis?: Vec3; + body?: Body; + + } + + export class WheelInfo { + + maxSuspensionTravbel: number; + customSlidingRotationalSpeed: number; + useCustomSlidingRotationalSpeed: boolean; + sliding: boolean; + chassisConnectionPointLocal: Vec3; + chassisConnectionPointWorld: Vec3; + directionLocal: Vec3; + directionWorld: Vec3; + axleLocal: Vec3; + axleWorld: Vec3; + suspensionRestLength: number; + suspensionMaxLength: number; + radius: number; + suspensionStiffness: number; + dampingCompression: number; + dampingRelaxation: number; + frictionSlip: number; + steering: number; + rotation: number; + deltaRotation: number; + rollInfluence: number; + maxSuspensionForce: number; + engineForce: number; + brake: number; + isFrontWheel: boolean; + clippedInvContactDotSuspension: number; + suspensionRelativeVelocity: number; + suspensionForce: number; + skidInfo: number; + suspensionLength: number; + sideImpulse: number; + forwardImpulse: number; + raycastResult: RaycastResult; + worldTransform: Transform; + isInContact: boolean; + + constructor(options?: IWheelInfoOptions); + + } + + export class RaycastVehicle { + + chassisBody: Body; + wheelInfos: IWheelInfoOptions[]; + sliding: boolean; + world: World; + iindexRightAxis: number; + indexForwardAxis: number; + indexUpAxis: number; + + constructor(options?: IRaycastVehicleOptions); + + addWheel(options?: IWheelInfoOptions): void; + setSteeringValue(value: number, wheelIndex: number): void; + applyEngineForce(value: number, wheelIndex: number): void; + setBrake(brake: number, wheelIndex: number): void; + addToWorld(world: World): void; + getVehicleAxisWorld(axisIndex: number, result: Vec3): Vec3; + updateVehicle(timeStep: number): void; + updateSuspension(deltaTime: number): void; + removeFromWorld(world: World): void; + getWheelTransformWorld(wheelIndex: number): Transform; + + } + + export interface IRigidVehicleOptions { + + chassisBody: Body; + + } + + export class RigidVehicle { + + wheelBodies: Body[]; + coordinateSystem: Vec3; + chassisBody: Body; + constraints: Constraint[]; + wheelAxes: Vec3[]; + wheelForces: Vec3[]; + + constructor(options?: IRigidVehicleOptions); + + addWheel(options?: IWheelInfoOptions): Body; + setSteeringValue(value: number, wheelIndex: number): void; + setMotorSpeed(value: number, wheelIndex: number): void; + disableMotor(wheelIndex: number): void; + setWheelForce(value: number, wheelIndex: number): void; + applyWheelForce(value: number, wheelIndex: number): void; + addToWorld(world: World): void; + removeFromWorld(world: World): void; + getWheelSpeed(wheelIndex: number): number; + + } + + export class SPHSystem { + + particles: Particle[]; + density: number; + smoothingRadius: number; + speedOfSound: number; + viscosity: number; + eps: number; + pressures: number[]; + densities: number[]; + neighbors: number[]; + + add(particle: Particle): void; + remove(particle: Particle): void; + getNeighbors(particle: Particle, neighbors: Particle[]): void; + update(): void; + w(r: number): number; + gradw(rVec: Vec3, resultVec: Vec3): void; + nablaw(r: number): number; + + } + + export interface ISpringOptions { + + restLength?: number; + stiffness?: number; + damping?: number; + worldAnchorA?: Vec3; + worldAnchorB?: Vec3; + localAnchorA?: Vec3; + localAnchorB?: Vec3; + + } + + export class Spring { + + restLength: number; + stffness: number; + damping: number; + bodyA: Body; + bodyB: Body; + localAnchorA: Vec3; + localAnchorB: Vec3; + + constructor(options?: ISpringOptions); + + setWorldAnchorA(worldAnchorA: Vec3): void; + setWorldAnchorB(worldAnchorB: Vec3): void; + getWorldAnchorA(result: Vec3): void; + getWorldAnchorB(result: Vec3): void; + applyForce(): void; + + } + + export class Box extends Shape { + + static calculateIntertia(halfExtents: Vec3, mass: number, target: Vec3): void; + + boundingSphereRadius: number; + collisionResponse: boolean; + halfExtents: Vec3; + convexPolyhedronRepresentation: ConvexPolyhedron; + + constructor(halfExtents: Vec3); + + updateConvexPolyhedronRepresentation(): void; + calculateLocalInertia(mass: number, target?: Vec3): Vec3; + getSideNormals(sixTargetVectors: boolean, quat?: Quaternion): Vec3[]; + updateBoundingSphereRadius(): number; + volume(): number; + forEachWorldCorner(pos: Vec3, quat: Quaternion, callback: Function): void; + + } + + export class ConvexPolyhedron extends Shape { + + static computeNormal(va: Vec3, vb: Vec3, vc: Vec3, target: Vec3): void; + static project(hull: ConvexPolyhedron, axis: Vec3, pos: Vec3, quat: Quaternion, result: number[]): void; + + vertices: Vec3[]; + worldVertices: Vec3[]; + worldVerticesNeedsUpdate: boolean; + faces: number[]; + faceNormals: Vec3[]; + uniqueEdges: Vec3[]; + + constructor(points?: Vec3[], faces?: number[]); + + computeEdges(): void; + computeNormals(): void; + getFaceNormal(i: number, target: Vec3): Vec3; + clipAgainstHull(posA: Vec3, quatA: Quaternion, hullB: Vec3, quatB: Quaternion, separatingNormal: Vec3, minDist: number, maxDist: number, result: any[]): void; + findSaparatingAxis(hullB: ConvexPolyhedron, posA: Vec3, quatA: Quaternion, posB: Vec3, quatB: Quaternion, target: Vec3, faceListA: any[], faceListB: any[]): boolean; + testSepAxis(axis: Vec3, hullB: ConvexPolyhedron, posA: Vec3, quatA: Quaternion, posB: Vec3, quatB: Quaternion): number; + getPlaneConstantOfFace(face_i: number): number; + clipFaceAgainstHull(separatingNormal: Vec3, posA: Vec3, quatA: Quaternion, worldVertsB1: Vec3[], minDist: number, maxDist: number, result: any[]): void; + clipFaceAgainstPlane(inVertices: Vec3[], outVertices: Vec3[], planeNormal: Vec3, planeConstant: number): Vec3; + computeWorldVertices(position: Vec3, quat: Quaternion): void; + computeLocalAABB(aabbmin: Vec3, aabbmax: Vec3): void; + computeWorldFaceNormals(quat: Quaternion): void; + calculateWorldAABB(pos: Vec3, quat: Quaternion, min: Vec3, max: Vec3): void; + getAveragePointLocal(target: Vec3): Vec3; + transformAllPoints(offset: Vec3, quat: Quaternion): void; + pointIsInside(p: Vec3): boolean; + + } + + export class Cylinder extends Shape { + + constructor(radiusTop: number, radiusBottom: number, height: number, numSegments: number); + + } + + export interface IHightfield { + + minValue?: number; + maxValue?: number; + elementSize: number; + + } + + export class Heightfield extends Shape { + + data: number[]; + maxValue: number; + minValue: number; + elementSize: number; + cacheEnabled: boolean; + pillarConvex: ConvexPolyhedron; + pillarOffset: Vec3; + type: number; + + constructor(data: number[], options?: IHightfield); + + update(): void; + updateMinValue(): void; + updateMaxValue(): void; + setHeightValueAtIndex(xi: number, yi: number, value: number): void; + getRectMinMax(iMinX: number, iMinY: number, iMaxX: number, iMaxY: number, result: any[]): void; + getIndexOfPosition(x: number, y: number, result: any[], clamp: boolean): boolean; + getConvexTrianglePillar(xi: number, yi: number, getUpperTriangle: boolean): void; + + } + + export class Particle extends Shape { + + } + + export class Plane extends Shape { + + worldNormal: Vec3; + worldNormalNeedsUpdate: boolean; + boundingSphereRadius: number; + + computeWorldNormal(quat: Quaternion): void; + calculateWorldAABB(pos: Vec3, quat: Quaternion, min: number, max: number): void; + + } + + export class Shape { + + static types: { + + SPHERE: number; + PLANE: number; + BOX: number; + COMPOUND: number; + CONVEXPOLYHEDRON: number; + HEIGHTFIELD: number; + PARTICLE: number; + CYLINDER: number; + + } + + type: number; + boundingSphereRadius: number; + collisionResponse: boolean; + + updateBoundingSphereRadius(): number; + volume(): number; + calculateLocalInertia(mass: number, target: Vec3): Vec3; + + } + + export class Sphere extends Shape { + + radius: number; + + constructor(radius: number); + + } + + export class GSSolver extends Solver { + + iterations: number; + tolerance: number; + + solve(dy: number, world: World): number; + + + } + + export class Solver { + iterations: number; + equations: Equation[]; + + solve(dy: number, world: World): number; + addEquation(eq: Equation): void; + removeEquation(eq: Equation): void; + removeAllEquations(): void; + + } + + export class SplitSolver extends Solver { + + subsolver: Solver; + + constructor(subsolver: Solver); + + solve(dy: number, world: World): number; + + } + + export class EventTarget { + + addEventListener(type: string, listener: Function): EventTarget; + hasEventListener(type: string, listener: Function): boolean; + removeEventListener(type: string, listener: Function): EventTarget; + dispatchEvent(event: IEvent): IEvent; + + } + + export class Pool { + + objects: any[]; + type: any[]; + + release(): any; + get(): any; + constructObject(): any; + + } + + export class TupleDictionary { + + data: { + keys: any[]; + }; + + get(i: number, j: number): number; + set(i: number, j: number, value: number): void; + reset(): void; + + } + + export class Utils { + + static defaults(options?: any, defaults?: any): any; + + } + + export class Vec3Pool extends Pool { + + type: any; + + constructObject(): Vec3; + + } + + export class NarrowPhase { + + contactPointPool: Pool[]; + v3pool: Vec3Pool; + + } + + export class World extends EventTarget { + + dt: number; + allowSleep: boolean; + contacts: ContactEquation[]; + frictionEquations: FrictionEquation[]; + quatNormalizeSkip: number; + quatNormalizeFast: boolean; + time: number; + stepnumber: number; + default_dt: number; + nextId: number; + gravity: Vec3; + broadphase: NaiveBroadphase; + bodies: Body[]; + solver: Solver; + constraints: Constraint[]; + narrowPhase: NarrowPhase; + collisionMatrix: ArrayCollisionMatrix; + collisionMatrixPrevious: ArrayCollisionMatrix; + materials: Material[]; + contactmaterials: ContactMaterial[]; + contactMaterialTable: TupleDictionary; + defaultMaterial: Material; + defaultContactMaterial: ContactMaterial; + doProfiling: boolean; + profile: { + solve: number; + makeContactConstraints: number; + broadphaser: number; + integrate: number; + narrowphase: number; + }; + subsystems: any[]; + addBodyEvent: IBodyEvent; + removeBodyEvent: IBodyEvent; + + getContactMaterial(m1: Material, m2: Material): ContactMaterial; + numObjects(): number; + collisionMatrixTick(): void; + addBody(body: Body): void; + addConstraint(c: Constraint): void; + removeConstraint(c: Constraint): void; + rayTest(from: Vec3, to: Vec3, result: RaycastResult): void; + remove(body: Body): void; + addMaterial(m: Material): void; + addContactMaterial(cmat: ContactMaterial): void; + step(dy: number, timeSinceLastCalled?: number, maxSubSteps?: number): void; + + } + + export interface IEvent { + + type: string; + + } + + export interface IBodyEvent extends IEvent { + + body: Body; + + } + +} diff --git a/cannon/tsconfig.json b/cannon/tsconfig.json new file mode 100644 index 0000000000..27e01ecd7b --- /dev/null +++ b/cannon/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} \ No newline at end of file diff --git a/rsvp/index.d.ts b/rsvp/index.d.ts new file mode 100644 index 0000000000..d10d3288da --- /dev/null +++ b/rsvp/index.d.ts @@ -0,0 +1,315 @@ +// Type definitions for RSVP 3.0.9 +// Project: github.com/tildeio/rsvp.js 3.0.9 +// Definitions by: Taylor Brown +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Some of this file was taken from the type definitions for es6-promise https://github.com/borisyankov/DefinitelyTyped/blob/master/es6-promise/es6-promise.d.ts +// Credit for that file goes to: François de Campredon + +// Some of this file was taken from the type definitions for Q : https://github.com/borisyankov/DefinitelyTyped/blob/master/q/Q.d.ts +// Credit for that file goes to: Barrie Nemetchek , Andrew Gaspar , John Reilly + +declare module RSVP { + + interface Thenable { + then(onFulfilled?:(value:R) => Thenable, onRejected?:(error:any) => Thenable): Thenable; + then(onFulfilled?:(value:R) => Thenable, onRejected?:(error:any) => U): Thenable; + then(onFulfilled?:(value:R) => Thenable, onRejected?:(error:any) => void): Thenable; + then(onFulfilled?:(value:R) => U, onRejected?:(error:any) => Thenable): Thenable; + then(onFulfilled?:(value:R) => U, onRejected?:(error:any) => U): Thenable; + then(onFulfilled?:(value:R) => U, onRejected?:(error:any) => void): Thenable; + } + + interface Deferred { + promise: Promise; + resolve(value: T): void; + reject(reason: any): void; + } + + class Promise implements Thenable { + /** + * If you call resolve in the body of the callback passed to the constructor, + * your promise is fulfilled with result object passed to resolve. + * If you call reject your promise is rejected with the object passed to resolve. + * For consistency and debugging (eg stack traces), obj should be an instanceof Error. + * Any errors thrown in the constructor callback will be implicitly passed to reject(). + */ + constructor(callback:(resolve:(result?:R) => void, reject:(error:any) => void) => void, label? : string); + + /** + * If you call resolve in the body of the callback passed to the constructor, + * your promise will be fulfilled/rejected with the outcome of thenable passed to resolve. + * If you call reject your promise is rejected with the object passed to resolve. + * For consistency and debugging (eg stack traces), obj should be an instanceof Error. + * Any errors thrown in the constructor callback will be implicitly passed to reject(). + */ + constructor(callback:(resolve:(thenable?:Thenable) => void, reject:(error:any) => void) => void, label? : string); + + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?:(value:R) => Thenable, onRejected?:(error:any) => Thenable):Promise; + + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?:(value:R) => Thenable, onRejected?:(error:any) => U):Promise; + + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?:(value:R) => Thenable, onRejected?:(error:any) => void):Promise; + + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?:(value:R) => U, onRejected?:(error:any) => Thenable):Promise; + + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?:(value:R) => U, onRejected?:(error:any) => U):Promise; + + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?:(value:R) => U, onRejected?:(error:any) => void):Promise; + + /** + * Sugar for promise.then(undefined, onRejected) + * + * @param onRejected called when/if "promise" rejects + */ + catch(onRejected?:(error:any) => Thenable):Promise; + + /** + * Sugar for promise.then(undefined, onRejected) + * + * @param onRejected called when/if "promise" rejects + */ + catch(onRejected?:(error:any) => U):Promise; + + /** + * Sugar for promise.then(undefined, onRejected) + * + * @param onRejected called when/if "promise" rejects + */ + catch(onRejected?:(error:any) => void):Promise; + + finally(finallyCallback: () => any): Promise; + + static all(promises: Thenable[]): Promise; + static all(promises: any[]): Promise; + static race(promises:Promise[]):Promise; + + /** + @method resolve + @param {Any} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` + */ + static resolve(object: Thenable): Promise; + static resolve(object: T): Promise; + + /** + @method cast (Deprecated in favor of resolve + @param {Any} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` + */ + static cast(object: Thenable, label? : string): Promise; + static cast(object: T, label? : string): Promise; + + /** + `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. + */ + static reject(reason?: any): Promise; + } + + interface PromiseState { + state: string /* "fulfilled", "rejected", "pending" */; + value?: T; + reason?: any; + } + + interface InstrumentEvent{ + guid:string; // guid of promise. Must be globally unique, not just within the implementation + childGuid:string; // child of child promise (for chained via `then`) + eventName:string; // one of ['created', 'chained', 'fulfilled', 'rejected'] + detail:any; // fulfillment value or rejection reason, if applicable + label:string; // label passed to promise's constructor + timeStamp:number; // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now + } + + export function on(eventName : string, callback: (value:any)=>void) : void; + export function on(eventName : "error", errorHandler: (reason:any)=>void): void; + export function on(eventName : "created", listener: (event:InstrumentEvent)=>void): void; + export function on(eventName : "chained", listener: (event:InstrumentEvent)=>void): void; + export function on(eventName : "fulfilled", listener: (event:InstrumentEvent)=>void): void; + export function on(eventName : "rejected", listener: (event:InstrumentEvent)=>void): void; + + export function configure(configName : string, value : any): void; + export function configure(configName : "instrument", shouldInstrument : boolean): void; + + /** + * configure('onerror', handler) is deprecated in favor of on('error', handler) + * @param configName + * @param errorHandler + */ + export function configure(configName : "onerror", errorHandler : (reason:any)=>void): void; + + /** + * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. + * the array passed to all can be a mixture of promise-like objects and other objects. + * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. + */ + export function all(promises: Thenable[]): Promise; + export function all(promises: any[]): Promise; + /** + * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. + * the array passed to all can be a mixture of promise-like objects and other objects. + * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. + * The key difference to the all() function is that both the fulfillment value and the argument to the hash() function + * are object literals. This allows you to simply reference the results directly off the returned object without + * having to remember the initial order like you would with all(). + * + */ + export function hash(promises: Thenable[]): Promise; + export function hash(promises: any[]): Promise; + + /** + `RSVP.map` is similar to JavaScript's native `map` method, except that it + waits for all promises to become fulfilled before running the `mapFn` on + each item in given to `promises`. `RSVP.map` returns a promise that will + become fulfilled with the result of running `mapFn` on the values the promises + become fulfilled with. + */ + export function map(promises: Thenable[], mapFn : (item:any)=>any, label? : string): Promise; + export function map(promises: any[], mapFn : (item:any)=>any, label? : string): Promise; + + + /** + * `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing + * a fail-fast method, it waits until all the promises have returned and + * shows you all the results. This is useful if you want to handle multiple + * promises' failure states together as a set. + */ + export function allSettled(promises: Thenable[]): Promise[]>; + export function allSettled(promises: any[]): Promise[]>; + + /** + * `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object + * instead of an array for its `promises` argument. + * + * Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method, + * but like `RSVP.allSettled`, `hashSettled` waits until all the + * constituent promises have returned and then shows you all the results + * with their states and values/reasons. This is useful if you want to + * handle multiple promises' failure states together as a set. + */ + export function hashSettled(promises: Thenable[]): Promise[]>; + export function hashSettled(promises: any[]): Promise[]>; + + /** + * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. + */ + function race(promises:Promise[]):Promise; + + /** + * `RSVP.denodeify` takes a "node-style" function and returns a function that + * will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the + * browser when you'd prefer to use promises over using callbacks. For example, + * `denodeify` transforms the following: + */ + export function denodeify(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise; + + /** + * Favor the Promise Constructor instead (if possible) + * + */ + export function defer(): Deferred; + + + /** + `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. + */ + export function reject(reason?: any): Promise; + + /** + `RSVP.Promise.resolve` returns a promise that will become resolved with the + passed `value`. + */ + export function resolve(object: Thenable): Promise; + export function resolve(object: T): Promise; + + /** + * `RSVP.filter` is similar to JavaScript's native `filter` method, except that it + * waits for all promises to become fulfilled before running the `filterFn` on + * each item in given to `promises`. `RSVP.filter` returns a promise that will + * become fulfilled with the result of running `filterFn` on the values the + * promises become fulfilled with. + */ + export function filter(promises: Thenable[], filterFn:(value:any)=>any): Promise; + + /** + `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event + loop in order to aid debugging. + + Promises A+ specifies that any exceptions that occur with a promise must be + caught by the promises implementation and bubbled to the last handler. For + this reason, it is recommended that you always specify a second rejection + handler function to `then`. However, `RSVP.rethrow` will throw the exception + outside of the promise, so it bubbles up to your console if in the browser, + or domain/cause uncaught exception in Node. `rethrow` will also throw the + error again so the error can be handled by the promise per the spec. + */ + export function rethrow(reason : any):void; + +} + diff --git a/rsvp/tsconfig.json b/rsvp/tsconfig.json new file mode 100644 index 0000000000..27e01ecd7b --- /dev/null +++ b/rsvp/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} \ No newline at end of file diff --git a/wonder-commonlib/index.d.ts b/wonder-commonlib/index.d.ts new file mode 100644 index 0000000000..2fd8d2bd88 --- /dev/null +++ b/wonder-commonlib/index.d.ts @@ -0,0 +1,258 @@ +declare module wdCb { + class JudgeUtils { + static isArray(arr: any): boolean; + static isArrayExactly(arr: any): boolean; + static isNumber(num: any): boolean; + static isNumberExactly(num: any): boolean; + static isString(str: any): boolean; + static isStringExactly(str: any): boolean; + static isBoolean(bool: any): boolean; + static isDom(obj: any): boolean; + static isObject(obj: any): boolean; + static isDirectObject(obj: any): boolean; + static isHostMethod(object: any, property: any): boolean; + static isNodeJs(): boolean; + static isFunction(func: any): boolean; + } +} + +declare var global: any, window: Window; +declare module wdCb { + var root: any; +} + +declare module wdCb { +} + +declare module wdCb { + const $BREAK: { + break: boolean; + }; + const $REMOVE: any; +} + +declare module wdCb { + class Log { + static info: { + INVALID_PARAM: string; + helperFunc: (...args: any[]) => string; + assertion: (...args: any[]) => any; + FUNC_INVALID: (...args: any[]) => any; + FUNC_MUST: (...args: any[]) => any; + FUNC_MUST_BE: (...args: any[]) => any; + FUNC_MUST_NOT_BE: (...args: any[]) => any; + FUNC_SHOULD: (...args: any[]) => any; + FUNC_SHOULD_NOT: (...args: any[]) => any; + FUNC_SUPPORT: (...args: any[]) => any; + FUNC_NOT_SUPPORT: (...args: any[]) => any; + FUNC_MUST_DEFINE: (...args: any[]) => any; + FUNC_MUST_NOT_DEFINE: (...args: any[]) => any; + FUNC_UNKNOW: (...args: any[]) => any; + FUNC_EXPECT: (...args: any[]) => any; + FUNC_UNEXPECT: (...args: any[]) => any; + FUNC_EXIST: (...args: any[]) => any; + FUNC_NOT_EXIST: (...args: any[]) => any; + FUNC_ONLY: (...args: any[]) => any; + FUNC_CAN_NOT: (...args: any[]) => any; + }; + static log(...messages: any[]): void; + static assert(cond: any, ...messages: any[]): void; + static error(cond: any, ...message: any[]): any; + static warn(...message: any[]): void; + private static _exec(consoleMethod, args, sliceBegin?); + } +} + +declare module wdCb { + class List { + protected children: Array; + getCount(): number; + hasChild(child: any): boolean; + hasChildWithFunc(func: Function): boolean; + getChildren(): T[]; + getChild(index: number): T; + addChild(child: T): this; + addChildren(arg: Array | List | any): this; + setChildren(children: Array): this; + unShiftChild(child: T): void; + removeAllChildren(): this; + forEach(func: Function, context?: any): this; + toArray(): T[]; + protected copyChildren(): T[]; + protected removeChildHelper(arg: any): Array; + private _forEach(arr, func, context?); + private _removeChild(arr, func); + } +} + +declare module wdCb { + class Collection extends List { + static create(children?: any[]): Collection; + constructor(children?: Array); + clone(): any; + clone(isDeep: boolean): any; + clone(target: Collection): any; + clone(target: Collection, isDeep: boolean): any; + filter(func: (value: T, index: number) => boolean): Collection; + findOne(func: (value: T, index: number) => boolean): T; + reverse(): Collection; + removeChild(arg: any): Collection; + sort(func: (a: T, b: T) => any, isSortSelf?: boolean): Collection; + map(func: (value: T, index: number) => any): Collection; + removeRepeatItems(): Collection; + hasRepeatItems(): false; + } +} + +declare module wdCb { + class Hash { + static create(children?: {}): Hash; + constructor(children?: { + [s: string]: T; + }); + private _children; + getChildren(): { + [s: string]: T; + }; + getCount(): number; + getKeys(): Collection; + getValues(): Collection; + getChild(key: string): T; + setValue(key: string, value: any): this; + addChild(key: string, value: any): this; + addChildren(arg: {} | Hash): this; + appendChild(key: string, value: any): this; + setChildren(children: { + [s: string]: T; + }): void; + removeChild(arg: any): Collection; + removeAllChildren(): void; + hasChild(key: string): boolean; + hasChildWithFunc(func: Function): boolean; + forEach(func: Function, context?: any): this; + filter(func: Function): Hash; + findOne(func: Function): any[]; + map(func: Function): Hash; + toCollection(): Collection; + toArray(): Array; + clone(): any; + clone(isDeep: boolean): any; + clone(target: Hash): any; + clone(target: Hash, isDeep: boolean): any; + } +} + +declare module wdCb { + class Queue extends List { + static create(children?: any[]): Queue; + constructor(children?: Array); + readonly front: T; + readonly rear: T; + push(element: T): void; + pop(): T; + clear(): void; + } +} + +declare module wdCb { + class Stack extends List { + static create(children?: any[]): Stack; + constructor(children?: Array); + readonly top: T; + push(element: T): void; + pop(): T; + clear(): void; + clone(): any; + clone(isDeep: boolean): any; + clone(target: Stack): any; + clone(target: Stack, isDeep: boolean): any; + filter(func: (value: T, index: number) => boolean): Collection; + findOne(func: (value: T, index: number) => boolean): T; + reverse(): Collection; + removeChild(arg: any): Collection; + sort(func: (a: T, b: T) => any, isSortSelf?: boolean): Collection; + map(func: (value: T, index: number) => any): Collection; + removeRepeatItems(): Collection; + hasRepeatItems(): false; + } +} + +declare module wdCb { + class AjaxUtils { + static ajax(conf: any): void; + private static _createAjax(error); + private static _isLocalFile(status); + private static _isSoundFile(dataType); + } +} + +declare module wdCb { + class ArrayUtils { + static removeRepeatItems(arr: Array, isEqual?: (a: any, b: any) => boolean): any[]; + static contain(arr: Array, ele: any): boolean; + } +} + +declare module wdCb { + class ConvertUtils { + static toString(obj: any): string; + private static _convertCodeToString(fn); + } +} + +declare module wdCb { + class EventUtils { + static bindEvent(context: any, func: any): (event: any) => any; + static addEvent(dom: any, eventName: any, handler: any): void; + static removeEvent(dom: any, eventName: any, handler: any): void; + } +} + +declare module wdCb { + class ExtendUtils { + static extendDeep(parent: any, child?: any, filter?: (val: any, i: any) => boolean): any; + static extend(destination: any, source: any): any; + static copyPublicAttri(source: any): {}; + } +} + +declare module wdCb { + class PathUtils { + static basename(path: string, ext?: string): string; + static changeExtname(pathStr: string, extname: string): string; + static changeBasename(pathStr: string, basename: string, isSameExt?: boolean): string; + static extname(path: string): string; + static dirname(path: string): string; + private static _splitPath(fileName); + } +} + +declare module wdCb { + class FunctionUtils { + static bind(object: any, func: Function): () => any; + } +} + +declare module wdCb { + class DomQuery { + static create(eleStr: string): any; + static create(dom: HTMLElement): any; + private _doms; + constructor(eleStr: string); + constructor(dom: HTMLElement); + get(index: any): HTMLElement; + prepend(eleStr: string): any; + prepend(dom: HTMLElement): any; + prependTo(eleStr: string): this; + remove(): this; + css(property: string, value: string): void; + attr(name: string): any; + attr(name: string, value: string): any; + text(str?: string): string; + private _isDomEleStr(eleStr); + private _buildDom(eleStr); + private _buildDom(dom); + private _createElement(eleStr); + } +} + diff --git a/wonder-commonlib/tsconfig.json b/wonder-commonlib/tsconfig.json new file mode 100644 index 0000000000..27e01ecd7b --- /dev/null +++ b/wonder-commonlib/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} \ No newline at end of file diff --git a/wonder-frp/index.d.ts b/wonder-frp/index.d.ts new file mode 100644 index 0000000000..8f77f93723 --- /dev/null +++ b/wonder-frp/index.d.ts @@ -0,0 +1,718 @@ +declare module wdFrp { + class JudgeUtils extends wdCb.JudgeUtils { + static isPromise(obj: any): boolean; + static isEqual(ob1: Entity, ob2: Entity): boolean; + static isIObserver(i: IObserver): () => any; + } +} + +declare module wdFrp { + var fromNodeCallback: (func: Function, context?: any) => (...funcArgs: any[]) => AnonymousStream; + var fromStream: (stream: any, finishEventName?: string) => AnonymousStream; + var fromReadableStream: (stream: any) => AnonymousStream; + var fromWritableStream: (stream: any) => AnonymousStream; + var fromTransformStream: (stream: any) => AnonymousStream; +} + +declare module wdFrp { + abstract class Entity { + static UID: number; + private _uid; + uid: string; + constructor(uidPre: string); + } +} + +declare module wdFrp { + class Main { + static isTest: boolean; + } +} + +declare module wdFrp { + function assert(cond: boolean, message?: string): void; + function require(InFunc: any): (target: any, name: any, descriptor: any) => any; + function ensure(OutFunc: any): (target: any, name: any, descriptor: any) => any; + function requireGetter(InFunc: any): (target: any, name: any, descriptor: any) => any; + function requireSetter(InFunc: any): (target: any, name: any, descriptor: any) => any; + function ensureGetter(OutFunc: any): (target: any, name: any, descriptor: any) => any; + function ensureSetter(OutFunc: any): (target: any, name: any, descriptor: any) => any; + function invariant(func: any): (target: any) => void; +} + +declare module wdFrp { + interface IDisposable { + dispose(): void; + } +} + +declare module wdFrp { + class SingleDisposable extends Entity implements IDisposable { + static create(disposeHandler?: Function): SingleDisposable; + private _disposeHandler; + private _isDisposed; + constructor(disposeHandler: Function); + setDisposeHandler(handler: Function): void; + dispose(): void; + } +} + +declare module wdFrp { + class GroupDisposable extends Entity implements IDisposable { + static create(disposable?: IDisposable): GroupDisposable; + private _group; + private _isDisposed; + constructor(disposable?: IDisposable); + add(disposable: IDisposable): this; + remove(disposable: IDisposable): this; + dispose(): void; + } +} + +declare module wdFrp { + interface IObserver extends IDisposable { + next(value: any): any; + error(error: any): any; + completed(): any; + } +} + +declare module wdFrp { + class InnerSubscription implements IDisposable { + static create(subject: Subject | GeneratorSubject, observer: Observer): InnerSubscription; + private _subject; + private _observer; + constructor(subject: Subject | GeneratorSubject, observer: Observer); + dispose(): void; + } +} + +declare module wdFrp { + class InnerSubscriptionGroup implements IDisposable { + static create(): InnerSubscriptionGroup; + private _container; + addChild(child: IDisposable): void; + dispose(): void; + } +} + +declare var global: any, window: Window; +declare module wdFrp { + var root: any; +} + +declare module wdFrp { +} + +declare module wdFrp { +} + +declare module wdFrp { +} + +declare module wdFrp { + abstract class Stream extends Entity { + scheduler: Scheduler; + subscribeFunc: (observer: IObserver) => Function | void; + constructor(subscribeFunc: any); + abstract subscribe(arg1: Function | Observer | Subject, onError?: Function, onCompleted?: Function): IDisposable; + buildStream(observer: IObserver): IDisposable; + do(onNext?: Function, onError?: Function, onCompleted?: Function): DoStream; + map(selector: Function): MapStream; + flatMap(selector: Function): MergeAllStream; + concatMap(selector: Function): any; + mergeAll(): MergeAllStream; + concatAll(): any; + skipUntil(otherStream: Stream): SkipUntilStream; + takeUntil(otherStream: Stream): TakeUntilStream; + take(count?: number): AnonymousStream; + takeLast(count?: number): AnonymousStream; + takeWhile(predicate: (value: any, index: number, source: Stream) => boolean, thisArg?: this): AnonymousStream; + lastOrDefault(defaultValue?: any): AnonymousStream; + filter(predicate: (value: any) => boolean, thisArg?: this): any; + filterWithState(predicate: (value: any) => boolean, thisArg?: this): any; + concat(streamArr: Array): any; + concat(...otherStream: any[]): any; + merge(maxConcurrent: number): any; + merge(streamArr: Array): any; + merge(...otherStreams: any[]): any; + repeat(count?: number): RepeatStream; + ignoreElements(): IgnoreElementsStream; + protected handleSubject(subject: any): boolean; + private _isSubject(subject); + private _setSubject(subject); + } +} + +declare module wdFrp { + class Scheduler { + static create(...args: any[]): Scheduler; + private _requestLoopId; + requestLoopId: any; + publishRecursive(observer: IObserver, initial: any, action: Function): void; + publishInterval(observer: IObserver, initial: any, interval: number, action: Function): number; + publishIntervalRequest(observer: IObserver, action: Function): void; + publishTimeout(observer: IObserver, time: number, action: Function): number; + } +} + +declare module wdFrp { + abstract class Observer extends Entity implements IObserver { + private _isDisposed; + isDisposed: boolean; + protected onUserNext: Function; + protected onUserError: Function; + protected onUserCompleted: Function; + private _isStop; + private _disposable; + constructor(observer: IObserver); + constructor(onNext: Function, onError: Function, onCompleted: Function); + next(value: any): any; + error(error: any): void; + completed(): void; + dispose(): void; + setDisposable(disposable: IDisposable): void; + protected abstract onNext(value: any): any; + protected abstract onError(error: any): any; + protected abstract onCompleted(): any; + } +} + +declare module wdFrp { + class Subject implements IObserver { + static create(): Subject; + private _source; + source: Stream; + private _observer; + subscribe(arg1?: Function | Observer, onError?: Function, onCompleted?: Function): IDisposable; + next(value: any): void; + error(error: any): void; + completed(): void; + start(): void; + remove(observer: Observer): void; + dispose(): void; + } +} + +declare module wdFrp { + class GeneratorSubject extends Entity implements IObserver { + static create(): GeneratorSubject; + private _isStart; + isStart: boolean; + constructor(); + observer: any; + onBeforeNext(value: any): void; + onAfterNext(value: any): void; + onIsCompleted(value: any): boolean; + onBeforeError(error: any): void; + onAfterError(error: any): void; + onBeforeCompleted(): void; + onAfterCompleted(): void; + subscribe(arg1?: Function | Observer, onError?: Function, onCompleted?: Function): IDisposable; + next(value: any): void; + error(error: any): void; + completed(): void; + toStream(): any; + start(): void; + stop(): void; + remove(observer: Observer): void; + dispose(): void; + } +} + +declare module wdFrp { + class AnonymousObserver extends Observer { + static create(onNext: Function, onError: Function, onCompleted: Function): AnonymousObserver; + protected onNext(value: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + } +} + +declare module wdFrp { + class AutoDetachObserver extends Observer { + static create(observer: IObserver): any; + static create(onNext: Function, onError: Function, onCompleted: Function): any; + dispose(): void; + protected onNext(value: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + } +} + +declare module wdFrp { + class MapObserver extends Observer { + static create(currentObserver: IObserver, selector: Function): MapObserver; + private _currentObserver; + private _selector; + constructor(currentObserver: IObserver, selector: Function); + protected onNext(value: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + } +} + +declare module wdFrp { + class DoObserver extends Observer { + static create(currentObserver: IObserver, prevObserver: IObserver): DoObserver; + private _currentObserver; + private _prevObserver; + constructor(currentObserver: IObserver, prevObserver: IObserver); + protected onNext(value: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + } +} + +declare module wdFrp { + class MergeAllObserver extends Observer { + static create(currentObserver: IObserver, streamGroup: wdCb.Collection, groupDisposable: GroupDisposable): MergeAllObserver; + constructor(currentObserver: IObserver, streamGroup: wdCb.Collection, groupDisposable: GroupDisposable); + done: boolean; + currentObserver: IObserver; + private _streamGroup; + private _groupDisposable; + protected onNext(innerSource: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + } +} + +declare module wdFrp { + class MergeObserver extends Observer { + static create(currentObserver: IObserver, maxConcurrent: number, streamGroup: wdCb.Collection, groupDisposable: GroupDisposable): MergeObserver; + constructor(currentObserver: IObserver, maxConcurrent: number, streamGroup: wdCb.Collection, groupDisposable: GroupDisposable); + done: boolean; + currentObserver: IObserver; + activeCount: number; + q: Array; + private _maxConcurrent; + private _groupDisposable; + private _streamGroup; + handleSubscribe(innerSource: any): void; + protected onNext(innerSource: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + private _isReachMaxConcurrent(); + } +} + +declare module wdFrp { + class TakeUntilObserver extends Observer { + static create(prevObserver: IObserver): TakeUntilObserver; + private _prevObserver; + constructor(prevObserver: IObserver); + protected onNext(value: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + } +} + +declare module wdFrp { + class SkipUntilSourceObserver extends Observer { + static create(prevObserver: IObserver, skipUntilStream: SkipUntilStream): SkipUntilSourceObserver; + private _prevObserver; + private _skipUntilStream; + constructor(prevObserver: IObserver, skipUntilStream: SkipUntilStream); + protected onNext(value: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + } +} + +declare module wdFrp { + class SkipUntilOtherObserver extends Observer { + static create(prevObserver: IObserver, skipUntilStream: SkipUntilStream): SkipUntilOtherObserver; + otherDisposable: IDisposable; + private _prevObserver; + private _skipUntilStream; + constructor(prevObserver: IObserver, skipUntilStream: SkipUntilStream); + protected onNext(value: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + } +} + +declare module wdFrp { + class ConcatObserver extends Observer { + static create(currentObserver: IObserver, startNextStream: Function): ConcatObserver; + protected currentObserver: any; + private _startNextStream; + constructor(currentObserver: IObserver, startNextStream: Function); + protected onNext(value: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + } +} + +declare module wdFrp { + interface ISubjectObserver { + addChild(observer: Observer): any; + removeChild(observer: Observer): any; + } +} + +declare module wdFrp { + class SubjectObserver implements IObserver { + observers: wdCb.Collection; + private _disposable; + isEmpty(): boolean; + next(value: any): void; + error(error: any): void; + completed(): void; + addChild(observer: Observer): void; + removeChild(observer: Observer): void; + dispose(): void; + setDisposable(disposable: IDisposable): void; + } +} + +declare module wdFrp { + class IgnoreElementsObserver extends Observer { + static create(currentObserver: IObserver): IgnoreElementsObserver; + private _currentObserver; + constructor(currentObserver: IObserver); + protected onNext(value: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + } +} + +declare module wdFrp { + class FilterObserver extends Observer { + static create(prevObserver: IObserver, predicate: (value: any, index?: number, source?: Stream) => boolean, source: Stream): FilterObserver; + constructor(prevObserver: IObserver, predicate: (value: any) => boolean, source: Stream); + protected prevObserver: IObserver; + protected source: Stream; + protected i: number; + protected predicate: (value: any, index?: number, source?: Stream) => boolean; + protected onNext(value: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + } +} + +declare module wdFrp { + class FilterWithStateObserver extends FilterObserver { + static create(prevObserver: IObserver, predicate: (value: any, index?: number, source?: Stream) => boolean, source: Stream): FilterWithStateObserver; + private _isTrigger; + protected onNext(value: any): void; + } +} + +declare module wdFrp { + abstract class BaseStream extends Stream { + abstract subscribeCore(observer: IObserver): IDisposable; + subscribe(arg1: Function | Observer | Subject, onError?: any, onCompleted?: any): IDisposable; + buildStream(observer: IObserver): IDisposable; + } +} + +declare module wdFrp { + class DoStream extends BaseStream { + static create(source: Stream, onNext?: Function, onError?: Function, onCompleted?: Function): DoStream; + private _source; + private _observer; + constructor(source: Stream, onNext: Function, onError: Function, onCompleted: Function); + subscribeCore(observer: IObserver): IDisposable; + } +} + +declare module wdFrp { + class MapStream extends BaseStream { + static create(source: Stream, selector: Function): MapStream; + private _source; + private _selector; + constructor(source: Stream, selector: Function); + subscribeCore(observer: IObserver): IDisposable; + } +} + +declare module wdFrp { + class FromArrayStream extends BaseStream { + static create(array: Array, scheduler: Scheduler): FromArrayStream; + private _array; + constructor(array: Array, scheduler: Scheduler); + subscribeCore(observer: IObserver): SingleDisposable; + } +} + +declare module wdFrp { + class FromPromiseStream extends BaseStream { + static create(promise: any, scheduler: Scheduler): FromPromiseStream; + private _promise; + constructor(promise: any, scheduler: Scheduler); + subscribeCore(observer: IObserver): SingleDisposable; + } +} + +declare module wdFrp { + class FromEventPatternStream extends BaseStream { + static create(addHandler: Function, removeHandler: Function): FromEventPatternStream; + private _addHandler; + private _removeHandler; + constructor(addHandler: Function, removeHandler: Function); + subscribeCore(observer: IObserver): SingleDisposable; + } +} + +declare module wdFrp { + class AnonymousStream extends Stream { + static create(subscribeFunc: Function): AnonymousStream; + constructor(subscribeFunc: Function); + subscribe(subject: Subject): IDisposable; + subscribe(observer: IObserver): IDisposable; + subscribe(onNext: (value: any) => void): IDisposable; + subscribe(onNext: (value: any) => void, onError: (e: any) => void): IDisposable; + subscribe(onNext: (value: any) => void, onError: (e: any) => void, onComplete: () => void): IDisposable; + } +} + +declare module wdFrp { + class IntervalStream extends BaseStream { + static create(interval: number, scheduler: Scheduler): IntervalStream; + private _interval; + constructor(interval: number, scheduler: Scheduler); + initWhenCreate(): void; + subscribeCore(observer: IObserver): SingleDisposable; + } +} + +declare module wdFrp { + class IntervalRequestStream extends BaseStream { + static create(scheduler: Scheduler): IntervalRequestStream; + private _isEnd; + constructor(scheduler: Scheduler); + subscribeCore(observer: IObserver): SingleDisposable; + } +} + +declare module wdFrp { + class TimeoutStream extends BaseStream { + static create(time: number, scheduler: Scheduler): TimeoutStream; + private _time; + constructor(time: number, scheduler: Scheduler); + subscribeCore(observer: IObserver): SingleDisposable; + } +} + +declare module wdFrp { + class MergeAllStream extends BaseStream { + static create(source: Stream): MergeAllStream; + constructor(source: Stream); + private _source; + private _observer; + subscribeCore(observer: IObserver): GroupDisposable; + } +} + +declare module wdFrp { + class MergeStream extends BaseStream { + static create(source: Stream, maxConcurrent: number): MergeStream; + constructor(source: Stream, maxConcurrent: number); + private _source; + private _maxConcurrent; + subscribeCore(observer: IObserver): GroupDisposable; + } +} + +declare module wdFrp { + class TakeUntilStream extends BaseStream { + static create(source: Stream, otherSteam: Stream): TakeUntilStream; + private _source; + private _otherStream; + constructor(source: Stream, otherStream: Stream); + subscribeCore(observer: IObserver): GroupDisposable; + } +} + +declare module wdFrp { + class SkipUntilStream extends BaseStream { + static create(source: Stream, otherSteam: Stream): SkipUntilStream; + isOpen: boolean; + private _source; + private _otherStream; + constructor(source: Stream, otherStream: Stream); + subscribeCore(observer: IObserver): GroupDisposable; + } +} + +declare module wdFrp { + class ConcatStream extends BaseStream { + static create(sources: Array): ConcatStream; + private _sources; + constructor(sources: Array); + subscribeCore(observer: IObserver): GroupDisposable; + } +} + +declare module wdFrp { + class RepeatStream extends BaseStream { + static create(source: Stream, count: number): RepeatStream; + private _source; + private _count; + constructor(source: Stream, count: number); + subscribeCore(observer: IObserver): GroupDisposable; + } +} + +declare module wdFrp { + class IgnoreElementsStream extends BaseStream { + static create(source: Stream): IgnoreElementsStream; + private _source; + constructor(source: Stream); + subscribeCore(observer: IObserver): IDisposable; + } +} + +declare module wdFrp { + class DeferStream extends BaseStream { + static create(buildStreamFunc: Function): DeferStream; + private _buildStreamFunc; + constructor(buildStreamFunc: Function); + subscribeCore(observer: IObserver): GroupDisposable; + } +} + +declare module wdFrp { + class FilterStream extends BaseStream { + static create(source: Stream, predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any): FilterStream; + constructor(source: Stream, predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any); + predicate: (value: any, index?: number, source?: Stream) => boolean; + private _source; + subscribeCore(observer: IObserver): IDisposable; + internalFilter(predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any): Stream; + protected createObserver(observer: IObserver): Observer; + protected createStreamForInternalFilter(source: Stream, innerPredicate: any, thisArg: any): Stream; + private _innerPredicate(predicate, self); + } +} + +declare module wdFrp { + class FilterWithStateStream extends FilterStream { + static create(source: Stream, predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any): FilterWithStateStream; + protected createObserver(observer: IObserver): FilterWithStateObserver; + protected createStreamForInternalFilter(source: Stream, innerPredicate: any, thisArg: any): Stream; + } +} + +declare module wdFrp { + var createStream: (subscribeFunc: any) => AnonymousStream; + var fromArray: (array: any[], scheduler?: Scheduler) => FromArrayStream; + var fromPromise: (promise: any, scheduler?: Scheduler) => FromPromiseStream; + var fromEventPattern: (addHandler: Function, removeHandler: Function) => FromEventPatternStream; + var interval: (interval: any, scheduler?: Scheduler) => IntervalStream; + var intervalRequest: (scheduler?: Scheduler) => IntervalRequestStream; + var timeout: (time: any, scheduler?: Scheduler) => TimeoutStream; + var empty: () => AnonymousStream; + var callFunc: (func: Function, context?: any) => AnonymousStream; + var judge: (condition: Function, thenSource: Function, elseSource: Function) => any; + var defer: (buildStreamFunc: Function) => DeferStream; + var just: (returnValue: any) => AnonymousStream; +} + +declare module wdFrp { + enum FilterState { + TRIGGER = 0, + ENTER = 1, + LEAVE = 2, + } +} + +declare module wdFrp { + class Record { + static create(time: number, value: any, actionType?: ActionType, comparer?: Function): Record; + private _time; + time: number; + private _value; + value: number; + private _actionType; + actionType: ActionType; + private _comparer; + constructor(time: any, value: any, actionType: ActionType, comparer: Function); + equals(other: any): any; + } +} + +declare module wdFrp { + class MockObserver extends Observer { + static create(scheduler: TestScheduler): MockObserver; + private _messages; + messages: [Record]; + private _scheduler; + constructor(scheduler: TestScheduler); + protected onNext(value: any): void; + protected onError(error: any): void; + protected onCompleted(): void; + dispose(): void; + clone(): MockObserver; + } +} + +declare module wdFrp { + class MockPromise { + static create(scheduler: TestScheduler, messages: [Record]): MockPromise; + private _messages; + private _scheduler; + constructor(scheduler: TestScheduler, messages: [Record]); + then(successCb: Function, errorCb: Function, observer: IObserver): void; + } +} + +declare module wdFrp { + class TestScheduler extends Scheduler { + static next(tick: any, value: any): Record; + static error(tick: any, error: any): Record; + static completed(tick: any): Record; + static create(isReset?: boolean): TestScheduler; + constructor(isReset: boolean); + private _clock; + clock: number; + private _isReset; + private _isDisposed; + private _timerMap; + private _streamMap; + private _subscribedTime; + private _disposedTime; + private _observer; + setStreamMap(observer: IObserver, messages: [Record]): void; + remove(observer: Observer): void; + publishRecursive(observer: MockObserver, initial: any, recursiveFunc: Function): void; + publishInterval(observer: IObserver, initial: any, interval: number, action: Function): number; + publishIntervalRequest(observer: IObserver, action: Function): number; + publishTimeout(observer: IObserver, time: number, action: Function): number; + private _setClock(); + startWithTime(create: Function, subscribedTime: number, disposedTime: number): MockObserver; + startWithSubscribe(create: any, subscribedTime?: number): MockObserver; + startWithDispose(create: any, disposedTime?: number): MockObserver; + publicAbsolute(time: any, handler: any): void; + start(): void; + createStream(args: any): TestStream; + createObserver(): MockObserver; + createResolvedPromise(time: number, value: any): MockPromise; + createRejectPromise(time: number, error: any): MockPromise; + private _getMinAndMaxTime(); + private _exec(time, map); + private _runStream(time); + private _runAt(time, callback); + private _tick(time); + } +} + +declare module wdFrp { + enum ActionType { + NEXT = 0, + ERROR = 1, + COMPLETED = 2, + } +} + +declare module wdFrp { + class TestStream extends BaseStream { + static create(messages: [Record], scheduler: TestScheduler): TestStream; + scheduler: TestScheduler; + private _messages; + constructor(messages: [Record], scheduler: TestScheduler); + subscribeCore(observer: IObserver): SingleDisposable; + } +} diff --git a/wonder-frp/tsconfig.json b/wonder-frp/tsconfig.json new file mode 100644 index 0000000000..27e01ecd7b --- /dev/null +++ b/wonder-frp/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} \ No newline at end of file From 6ab43d89ceb253203ea9c7eb19d5acc27428cd03 Mon Sep 17 00:00:00 2001 From: yyc <395976266@qq.com> Date: Sun, 22 Jan 2017 08:19:18 +0800 Subject: [PATCH 2/7] fix: add header in .d.ts file fix: add tests file fix: set "strictNullChecks": true --- cannon/cannon-tests.ts | 6 ++++++ cannon/index.d.ts | 5 +++++ cannon/tsconfig.json | 2 +- cannon/tslint.json | 1 + rsvp/rsvp-tests.ts | 4 ++++ rsvp/tsconfig.json | 2 +- wonder-commonlib/index.d.ts | 5 +++++ wonder-commonlib/tsconfig.json | 2 +- wonder-commonlib/wonder-commonlib-tests.ts | 7 +++++++ wonder-frp/index.d.ts | 5 +++++ wonder-frp/tsconfig.json | 2 +- wonder-frp/wonder-frp-tests.ts | 6 ++++++ 12 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 cannon/cannon-tests.ts create mode 100644 cannon/tslint.json create mode 100644 rsvp/rsvp-tests.ts create mode 100644 wonder-commonlib/wonder-commonlib-tests.ts create mode 100644 wonder-frp/wonder-frp-tests.ts diff --git a/cannon/cannon-tests.ts b/cannon/cannon-tests.ts new file mode 100644 index 0000000000..f68a96d811 --- /dev/null +++ b/cannon/cannon-tests.ts @@ -0,0 +1,6 @@ +import cannon = require("cannon"); + +var aabb = new cannon.AABB() + +aabb.setFromPoints(new cannon.Vec3(1,2,3)); + diff --git a/cannon/index.d.ts b/cannon/index.d.ts index 90493d5edd..ea8ae89e59 100644 --- a/cannon/index.d.ts +++ b/cannon/index.d.ts @@ -1,3 +1,8 @@ +// Type definitions for cannon +// Project: https://github.com/clark-stevenson/cannon.d.ts +// Definitions by: Clark Stevenson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + declare module CANNON { export interface IAABBOptions { diff --git a/cannon/tsconfig.json b/cannon/tsconfig.json index 27e01ecd7b..3bc13b0278 100644 --- a/cannon/tsconfig.json +++ b/cannon/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/cannon/tslint.json b/cannon/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/cannon/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file diff --git a/rsvp/rsvp-tests.ts b/rsvp/rsvp-tests.ts new file mode 100644 index 0000000000..efb3cdbff6 --- /dev/null +++ b/rsvp/rsvp-tests.ts @@ -0,0 +1,4 @@ +var rsvp = require("rsvp"); + +var promise = new rsvp.Promise(function(resolve, rejector){ +}); diff --git a/rsvp/tsconfig.json b/rsvp/tsconfig.json index 27e01ecd7b..3bc13b0278 100644 --- a/rsvp/tsconfig.json +++ b/rsvp/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/wonder-commonlib/index.d.ts b/wonder-commonlib/index.d.ts index 2fd8d2bd88..899def415f 100644 --- a/wonder-commonlib/index.d.ts +++ b/wonder-commonlib/index.d.ts @@ -1,3 +1,8 @@ +// Type definitions for wonder-commonlib v0.1.0 +// Project: https://github.com/yyc-git/Wonder-CommonLib +// Definitions by: YYC +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + declare module wdCb { class JudgeUtils { static isArray(arr: any): boolean; diff --git a/wonder-commonlib/tsconfig.json b/wonder-commonlib/tsconfig.json index 27e01ecd7b..3bc13b0278 100644 --- a/wonder-commonlib/tsconfig.json +++ b/wonder-commonlib/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/wonder-commonlib/wonder-commonlib-tests.ts b/wonder-commonlib/wonder-commonlib-tests.ts new file mode 100644 index 0000000000..fb84bc3a5e --- /dev/null +++ b/wonder-commonlib/wonder-commonlib-tests.ts @@ -0,0 +1,7 @@ +var wdCb = require("wonder-commonlib"); + +var list = wdCb.Collection.create(); + +list.addChild(1); + + diff --git a/wonder-frp/index.d.ts b/wonder-frp/index.d.ts index 8f77f93723..cf7ca6fd78 100644 --- a/wonder-frp/index.d.ts +++ b/wonder-frp/index.d.ts @@ -1,3 +1,8 @@ +// Type definitions for wonder-frp v0.1.0 +// Project: https://github.com/yyc-git/Wonder-FRP +// Definitions by: YYC +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + declare module wdFrp { class JudgeUtils extends wdCb.JudgeUtils { static isPromise(obj: any): boolean; diff --git a/wonder-frp/tsconfig.json b/wonder-frp/tsconfig.json index 27e01ecd7b..3bc13b0278 100644 --- a/wonder-frp/tsconfig.json +++ b/wonder-frp/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/wonder-frp/wonder-frp-tests.ts b/wonder-frp/wonder-frp-tests.ts new file mode 100644 index 0000000000..8bfebf55ba --- /dev/null +++ b/wonder-frp/wonder-frp-tests.ts @@ -0,0 +1,6 @@ +var wdFrp = require("wonder-frp"); + +wdFrp.fromArray([1,2,3]) + .subscribe(null,null,function(){ + console.log("completed"); + }); From e8cb9198fb92e483e1ecaec213db49483c87fa90 Mon Sep 17 00:00:00 2001 From: yyc <395976266@qq.com> Date: Sun, 22 Jan 2017 08:26:23 +0800 Subject: [PATCH 3/7] fix: used tests file --- cannon/tsconfig.json | 3 ++- rsvp/tsconfig.json | 3 ++- wonder-commonlib/tsconfig.json | 3 ++- wonder-frp/tsconfig.json | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cannon/tsconfig.json b/cannon/tsconfig.json index 3bc13b0278..a59be4d465 100644 --- a/cannon/tsconfig.json +++ b/cannon/tsconfig.json @@ -16,6 +16,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "cannon-tests.ts" ] } \ No newline at end of file diff --git a/rsvp/tsconfig.json b/rsvp/tsconfig.json index 3bc13b0278..58c8e605be 100644 --- a/rsvp/tsconfig.json +++ b/rsvp/tsconfig.json @@ -16,6 +16,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "rsvp-tests.ts" ] } \ No newline at end of file diff --git a/wonder-commonlib/tsconfig.json b/wonder-commonlib/tsconfig.json index 3bc13b0278..19de8e5e84 100644 --- a/wonder-commonlib/tsconfig.json +++ b/wonder-commonlib/tsconfig.json @@ -16,6 +16,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "wonder-commonlib-tests.ts" ] } \ No newline at end of file diff --git a/wonder-frp/tsconfig.json b/wonder-frp/tsconfig.json index 3bc13b0278..606dd8ac8c 100644 --- a/wonder-frp/tsconfig.json +++ b/wonder-frp/tsconfig.json @@ -16,6 +16,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "wonder-frp-tests.ts" ] } \ No newline at end of file From a8b09e012a2101035e9236334dd5b870b539420c Mon Sep 17 00:00:00 2001 From: yyc <395976266@qq.com> Date: Sun, 22 Jan 2017 08:39:12 +0800 Subject: [PATCH 4/7] fix --- cannon/index.d.ts | 4 ++++ rsvp/index.d.ts | 4 ++++ rsvp/rsvp-tests.ts | 4 ++-- wonder-commonlib/index.d.ts | 6 +++++- wonder-commonlib/wonder-commonlib-tests.ts | 2 +- wonder-frp/index.d.ts | 5 +++++ wonder-frp/wonder-frp-tests.ts | 2 +- 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/cannon/index.d.ts b/cannon/index.d.ts index ea8ae89e59..6b4905c7b1 100644 --- a/cannon/index.d.ts +++ b/cannon/index.d.ts @@ -992,3 +992,7 @@ declare module CANNON { } } + +declare module "cannon" { + export = CANNON; +} diff --git a/rsvp/index.d.ts b/rsvp/index.d.ts index d10d3288da..f4a8fd0a1a 100644 --- a/rsvp/index.d.ts +++ b/rsvp/index.d.ts @@ -313,3 +313,7 @@ declare module RSVP { } + +declare module "rsvp" { + export = RSVP; +} diff --git a/rsvp/rsvp-tests.ts b/rsvp/rsvp-tests.ts index efb3cdbff6..50770ba8b6 100644 --- a/rsvp/rsvp-tests.ts +++ b/rsvp/rsvp-tests.ts @@ -1,4 +1,4 @@ -var rsvp = require("rsvp"); +import rsvp = require("rsvp"); -var promise = new rsvp.Promise(function(resolve, rejector){ +var promise = new rsvp.Promise(function(resolve:any, rejector:any){ }); diff --git a/wonder-commonlib/index.d.ts b/wonder-commonlib/index.d.ts index 899def415f..ab27ce88ff 100644 --- a/wonder-commonlib/index.d.ts +++ b/wonder-commonlib/index.d.ts @@ -21,7 +21,7 @@ declare module wdCb { } } -declare var global: any, window: Window; +declare var global: any, window: any; declare module wdCb { var root: any; } @@ -261,3 +261,7 @@ declare module wdCb { } } +declare module "wonder-commonlib" { + export = wdCb; +} + diff --git a/wonder-commonlib/wonder-commonlib-tests.ts b/wonder-commonlib/wonder-commonlib-tests.ts index fb84bc3a5e..c22d61c11d 100644 --- a/wonder-commonlib/wonder-commonlib-tests.ts +++ b/wonder-commonlib/wonder-commonlib-tests.ts @@ -1,4 +1,4 @@ -var wdCb = require("wonder-commonlib"); +import wdCb = require("wonder-commonlib"); var list = wdCb.Collection.create(); diff --git a/wonder-frp/index.d.ts b/wonder-frp/index.d.ts index cf7ca6fd78..eda41a0370 100644 --- a/wonder-frp/index.d.ts +++ b/wonder-frp/index.d.ts @@ -721,3 +721,8 @@ declare module wdFrp { subscribeCore(observer: IObserver): SingleDisposable; } } + +declare module "wonder-frp" { + export = wdFrp; +} + diff --git a/wonder-frp/wonder-frp-tests.ts b/wonder-frp/wonder-frp-tests.ts index 8bfebf55ba..8f93f0462c 100644 --- a/wonder-frp/wonder-frp-tests.ts +++ b/wonder-frp/wonder-frp-tests.ts @@ -1,4 +1,4 @@ -var wdFrp = require("wonder-frp"); +import wdFrp = require("wonder-frp"); wdFrp.fromArray([1,2,3]) .subscribe(null,null,function(){ From 29bcff2afd0f1f8d5e61f1cc5513da4f8dcf9665 Mon Sep 17 00:00:00 2001 From: yyc <395976266@qq.com> Date: Sun, 22 Jan 2017 09:27:42 +0800 Subject: [PATCH 5/7] fix --- cannon/cannon-tests.ts | 2 +- wonder-commonlib/tsconfig.json | 3 ++- wonder-frp/index.d.ts | 4 +++- wonder-frp/wonder-frp-tests.ts | 3 +-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cannon/cannon-tests.ts b/cannon/cannon-tests.ts index f68a96d811..79ae76a6d8 100644 --- a/cannon/cannon-tests.ts +++ b/cannon/cannon-tests.ts @@ -2,5 +2,5 @@ import cannon = require("cannon"); var aabb = new cannon.AABB() -aabb.setFromPoints(new cannon.Vec3(1,2,3)); +aabb.setFromPoints([new cannon.Vec3(1,2,3)]); diff --git a/wonder-commonlib/tsconfig.json b/wonder-commonlib/tsconfig.json index 19de8e5e84..3540cf91c0 100644 --- a/wonder-commonlib/tsconfig.json +++ b/wonder-commonlib/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/wonder-frp/index.d.ts b/wonder-frp/index.d.ts index eda41a0370..a5c89af7c3 100644 --- a/wonder-frp/index.d.ts +++ b/wonder-frp/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: YYC // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + declare module wdFrp { class JudgeUtils extends wdCb.JudgeUtils { static isPromise(obj: any): boolean; @@ -101,7 +103,7 @@ declare module wdFrp { } } -declare var global: any, window: Window; +declare var global: any, window: any; declare module wdFrp { var root: any; } diff --git a/wonder-frp/wonder-frp-tests.ts b/wonder-frp/wonder-frp-tests.ts index 8f93f0462c..3efceed43f 100644 --- a/wonder-frp/wonder-frp-tests.ts +++ b/wonder-frp/wonder-frp-tests.ts @@ -1,6 +1,5 @@ import wdFrp = require("wonder-frp"); wdFrp.fromArray([1,2,3]) - .subscribe(null,null,function(){ - console.log("completed"); + .subscribe(function(){ }); From fc94866d7b48d9226dde14bb3aaf87b17901acff Mon Sep 17 00:00:00 2001 From: yyc <395976266@qq.com> Date: Sun, 22 Jan 2017 09:34:27 +0800 Subject: [PATCH 6/7] fix --- wonder-commonlib/index.d.ts | 2 +- wonder-frp/index.d.ts | 2 +- wonder-frp/tsconfig.json | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wonder-commonlib/index.d.ts b/wonder-commonlib/index.d.ts index ab27ce88ff..3421de0125 100644 --- a/wonder-commonlib/index.d.ts +++ b/wonder-commonlib/index.d.ts @@ -21,7 +21,7 @@ declare module wdCb { } } -declare var global: any, window: any; +declare var global: any, window: Window; declare module wdCb { var root: any; } diff --git a/wonder-frp/index.d.ts b/wonder-frp/index.d.ts index a5c89af7c3..c5e69d2dd9 100644 --- a/wonder-frp/index.d.ts +++ b/wonder-frp/index.d.ts @@ -103,7 +103,7 @@ declare module wdFrp { } } -declare var global: any, window: any; +declare var global: any, window: Window; declare module wdFrp { var root: any; } diff --git a/wonder-frp/tsconfig.json b/wonder-frp/tsconfig.json index 606dd8ac8c..bc145951ba 100644 --- a/wonder-frp/tsconfig.json +++ b/wonder-frp/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, From d3ce3c24728023f0766714c623194c6fb8bb415e Mon Sep 17 00:00:00 2001 From: yyc <395976266@qq.com> Date: Sun, 22 Jan 2017 09:53:42 +0800 Subject: [PATCH 7/7] fix --- cannon/index.d.ts | 377 +++++++++++++++++++++++++++++++++++---------- cannon/tslint.json | 1 - 2 files changed, 292 insertions(+), 86 deletions(-) delete mode 100644 cannon/tslint.json diff --git a/cannon/index.d.ts b/cannon/index.d.ts index 6b4905c7b1..7df6671d52 100644 --- a/cannon/index.d.ts +++ b/cannon/index.d.ts @@ -19,11 +19,14 @@ declare module CANNON { constructor(options?: IAABBOptions); + clone() : AABB; setFromPoints(points: Vec3[], position?: Vec3, quaternion?: Quaternion, skinSize?: number): void; copy(aabb: AABB): void; extend(aabb: AABB): void; + getCorners( a: Vec3, b: Vec3, c: Vec3, d: Vec3, e: Vec3, f: Vec3, g: Vec3, h: Vec3 ) : void; overlaps(aabb: AABB): boolean; - + toLocalFrame( frame: Transform, target: AABB ) : AABB; + toWorldFrame( frame: Transform, target: AABB ) : AABB; } export class ArrayCollisionMatrix { @@ -37,7 +40,7 @@ declare module CANNON { } - export class BroadPhase { + export class Broadphase { world: World; useBoundingBoxes: boolean; @@ -55,7 +58,7 @@ declare module CANNON { } - export class GridBroadphase extends BroadPhase { + export class GridBroadphase extends Broadphase { nx: number; ny: number; @@ -68,7 +71,7 @@ declare module CANNON { } - export class NaiveBroadphase extends BroadPhase { + export class NaiveBroadphase extends Broadphase { } export class ObjectCollisionMatrix { @@ -82,16 +85,42 @@ declare module CANNON { } + export interface IRayIntersectWorldOptions { + + mode: number; + result: boolean; + skipBackfaces: boolean; + collisionFilterMask: number; + collisionFilterGroup: number; + from: Vec3; + to: Vec3; + callback: Function; + + } + export class Ray { + static CLOSEST: number; + static ANY: number; + static ALL: number; + from: Vec3; to: Vec3; precision: number; checkCollisionResponse: boolean; + callback: Function; + collisionFilterGroup: number; + collisionFilterMask: number; + hasHit: boolean; + mode: number; + result: RaycastResult; + skipBackfaces: boolean; constructor(from?: Vec3, to?: Vec3); getAABB(result: RaycastResult): void; + intersectBodies(bodies: Body[], result?: RaycastResult): void; + intersectWorld(world: World, options: IRayIntersectWorldOptions): boolean; } @@ -101,17 +130,19 @@ declare module CANNON { rayToWorld: Vec3; hitNormalWorld: Vec3; hitPointWorld: Vec3; + hitFaceIndex: number; hasHit: boolean; shape: Shape; body: Body; distance: number; + abort(): void; reset(): void; set(rayFromWorld: Vec3, rayToWorld: Vec3, hitNormalWorld: Vec3, hitPointWorld: Vec3, shape: Shape, body: Body, distance: number): void; } - export class SAPBroadphase extends BroadPhase { + export class SAPBroadphase extends Broadphase { static insertionSortX(a: any[]): any[]; static insertionSortY(a: any[]): any[]; @@ -147,12 +178,17 @@ declare module CANNON { constructor(bodyA: Body, bodyB: Body, options?: IConstraintOptions); update(): void; + disable(): void; + enable(): void; } export class DistanceConstraint extends Constraint { - constructor(bodyA: Body, bodyB: Body, distance: number, maxForce?: number); + distance: number; + distanceEquation: ContactEquation; + + constructor(bodyA: Body, bodyB: Body, distance?: number, maxForce?: number); } @@ -168,6 +204,10 @@ declare module CANNON { export class HingeConstraint extends Constraint { + axisA: Vec3; + axisB: Vec3; + rotationalEquation1: RotationalEquation; + rotationalEquation2: RotationalEquation; motorEnabled: boolean; motorTargetVelocity: number; motorMinForce: number; @@ -178,21 +218,41 @@ declare module CANNON { enableMotor(): void; disableMotor(): void; + setMotorMaxForce(maxForce: number): void; + setMotorSpeed(speed: number): void; } export class PointToPointConstraint extends Constraint { + equationX: ContactEquation; + equationY: ContactEquation; + equationZ: ContactEquation; + pivotA: Vec3; + pivotB: Vec3; + constructor(bodyA: Body, pivotA: Vec3, bodyB: Body, pivotB: Vec3, maxForce?: number); } + export class ConeTwistConstraint extends PointToPointConstraint { + + coneEquation: ConeEquation; + twistEquation: RotationalEquation; + + constructor(bodyA: Body, bodyB: Body, options?: IHingeConstraintOptions); - export class LockConstraint extends Constraint { - constructor(bodyA: Body, bodyB: Body, options?:any); } + export class LockConstraint extends PointToPointConstraint { + rotationalEquation1: RotationalEquation; + rotationalEquation2: RotationalEquation; + rotationalEquation3: RotationalEquation; + + constructor(bodyA: Body, bodyB: Body, maxForce?: number); + + } export class Equation { @@ -219,7 +279,7 @@ declare module CANNON { computeGiMGt(): number; addToWlamda(deltalambda: number): number; computeC(): number; - + computeInvC( eps: number ): number; } export class FrictionEquation extends Equation { @@ -228,6 +288,14 @@ declare module CANNON { } + export interface IRotationalEquationOptions { + + axisA?: Vec3; + axisB?: Vec3; + maxForce?: number; + + } + export class RotationalEquation extends Equation { ni: Vec3; @@ -239,7 +307,7 @@ declare module CANNON { relVel: Vec3; relForce: Vec3; - constructor(bodyA: Body, bodyB: Body); + constructor(bodyA: Body, bodyB: Body, options?: IRotationalEquationOptions); } @@ -255,22 +323,33 @@ declare module CANNON { } + export interface IConeEquationOptions { + + axisA?: Vec3; + axisB?: Vec3; + maxForce?: number; + + } + + export class ConeEquation extends Equation { + + angle: number; + + constructor(bodyA: Body, bodyB: Body, options?: IConeEquationOptions); + + } + export class ContactEquation extends Equation { restitution: number; ri: Vec3; rj: Vec3; - penetrationVec: Vec3; ni: Vec3; - rixn: Vec3; - rjxn: Vec3; - invIi: Mat3; - invIj: Mat3; - biInvInertiaTimesRixn: Vec3; - bjInvInertiaTimesRjxn: Vec3; constructor(bi: Body, bj: Body); + getImpactVelocityAlongNormal(): number; + } export interface IContactMaterialOptions { @@ -301,12 +380,12 @@ declare module CANNON { export class Material { - name: string; id: number; - friction:number; - restitution:number; + name: string; + friction: number; + restitution: number; - constructor(name: string); + constructor(name?: string); } @@ -322,6 +401,8 @@ declare module CANNON { export class Mat3 { + elements: number[]; + constructor(elements?: number[]); identity(): void; @@ -342,6 +423,38 @@ declare module CANNON { } + export class Trimesh extends Shape { + + aabb: AABB; + edges: number[]; + indices: number[]; + normals: number[]; + scale: Vec3; + tree: Octree; + vertices: number[]; + + static computeNormal(va: Vec3, vb: Vec3, vc: Vec3, target: Vec3): void; + static createTorus(radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, arc?: number): Trimesh; + + constructor(vertices: number[], indices: number[]); + + calculateWorldAABB(pos: Vec3, quat: Quaternion, min: Vec3, max: Vec3): void; + computeLocalAABB(aabb: AABB): void; + getEdgeVector(edgeIndex: number, vectorStore: Vec3): void; + getEdgeVertex(edgeIndex: number, firstOrSecond: number, vertexStore: Vec3): void; + getNormal(i: number, target: Vec3): Vec3; + getTrianglesAABB(aabb: AABB, result: number[]): void; + getTriangleVertices(i: number, a: Vec3, b: Vec3, c: Vec3): void; + getVertex(i: number, out: Vec3): Vec3; + getWorldVertex(i: number, pos: Vec3, quat: Quaternion, out: Vec3): Vec3; + setScale(scale: Vec3): void; + updateAABB(): void; + updateEdges(): void; + updateNormals(): void; + updateTree(): void; + + } + export class Quaternion { x: number; @@ -374,18 +487,23 @@ declare module CANNON { static pointToLocalFrame(position: Vec3, quaternion: Quaternion, worldPoint: Vec3, result?: Vec3): Vec3; static pointToWorldFrame(position: Vec3, quaternion: Quaternion, localPoint: Vec3, result?: Vec3): Vec3; + static vectorToWorldFrame(quaternion: Quaternion, localVector: Vec3, result: Vec3): Vec3; + static vectorToLocalFrame(position: Vec3, quaternion: Quaternion, worldVector: Vec3, result?: Vec3): Vec3; position: Vec3; quaternion: Quaternion; - vectorToWorldFrame(localVector: Vec3, result?: Vec3): Vec3; - vectorToLocalFrame(position: Vec3, quaternion: Quaternion, worldVector: Vec3, result?: Vec3): Vec3; + pointToLocal(point: Vec3, result: Vec3): Vec3; + pointToWorld(point: Vec3, result: Vec3): Vec3; } export class Vec3 { static ZERO: Vec3; + static UNIT_X: Vec3; + static UNIT_Y: Vec3; + static UNIT_Z: Vec3; x: number; y: number; @@ -404,6 +522,7 @@ declare module CANNON { norm(): number; norm2(): number; distanceTo(p: Vec3): number; + distanceSquared(p: Vec3): number; mult(scalar: number, target?: Vec3): Vec3; scale(scalar: number, target?: Vec3): Vec3; dot(v: Vec3): number; @@ -413,6 +532,8 @@ declare module CANNON { toString(): string; toArray(): number[]; copy(source: Vec3): Vec3; + length(): number; + lengthSquared(): number; lerp(v: Vec3, t: number, target?: Vec3): void; almostEquals(v: Vec3, precision?: number): boolean; almostZero(precision?: number): boolean; @@ -422,15 +543,24 @@ declare module CANNON { } export interface IBodyOptions { + position?: Vec3; velocity?: Vec3; angularVelocity?: Vec3; quaternion?: Quaternion; mass?: number; - material?: number; + material?: Material; type?: number; linearDamping?: number; angularDamping?: number; + allowSleep?: boolean; + sleepSpeedLimit?: number; + sleepTimeLimit?: number; + collisionFilterGroup?: number; + collisionFilterMask?: number; + fixedRotation?: boolean; + shape?: Shape; + } export class Body extends EventTarget { @@ -455,6 +585,7 @@ declare module CANNON { position: Vec3; previousPosition: Vec3; initPosition: Vec3; + boundingRadius: number; velocity: Vec3; initVelocity: Vec3; force: Vec3; @@ -495,30 +626,24 @@ declare module CANNON { wakeUp(): void; sleep(): void; sleepTick(time: number): void; - updateSolveMassProperties(): void; pointToLocalFrame(worldPoint: Vec3, result?: Vec3): Vec3; pointToWorldFrame(localPoint: Vec3, result?: Vec3): Vec3; + vectorToLocalFrame(worldPoint: Vec3, result?: Vec3): Vec3; vectorToWorldFrame(localVector: Vec3, result?: Vec3): Vec3; - addShape(shape: Shape, offset?: Vec3, orientation?: Quaternion): void; - updateBoundingRadius(): void; + addShape(shape: Shape, offset?: Vec3, orientation?: Vec3): void; computeAABB(): void; - updateInertiaWorld(force: Vec3): void; applyForce(force: Vec3, worldPoint: Vec3): void; applyImpulse(impulse: Vec3, worldPoint: Vec3): void; + applyLocalForce(force: Vec3, localPoint: Vec3): void; + applyLocalImplse(impulse: Vec3, localPoint: Vec3): void; + updateBoundingRadius(): void; updateMassProperties(): void; + updateInertiaWorld(force: Vec3): void; + updateSolveMassProperties(): void; getVelocityAtWorldPoint(worldPoint: Vec3, result: Vec3): Vec3; } - export interface IRaycastVehicleOptions { - - chassisBody?: Body; - indexRightAxis?: number; - indexLeftAxis?: number; - indexUpAxis?: number; - - } - export interface IWheelInfoOptions { chassisConnectionPointLocal?: Vec3; @@ -539,7 +664,7 @@ declare module CANNON { deltaRotation?: number; rollInfluence?: number; maxSuspensionForce?: number; - isFronmtWheel?: boolean; + isFrontWheel?: boolean; clippedInvContactDotSuspension?: number; suspensionRelativeVelocity?: number; suspensionForce?: number; @@ -558,46 +683,55 @@ declare module CANNON { export class WheelInfo { - maxSuspensionTravbel: number; - customSlidingRotationalSpeed: number; - useCustomSlidingRotationalSpeed: boolean; - sliding: boolean; - chassisConnectionPointLocal: Vec3; - chassisConnectionPointWorld: Vec3; - directionLocal: Vec3; - directionWorld: Vec3; axleLocal: Vec3; axleWorld: Vec3; - suspensionRestLength: number; - suspensionMaxLength: number; - radius: number; - suspensionStiffness: number; + brake: number; + chassisConnectionPointLocal: Vec3; + chassisConnectionPointWorld: Vec3; + clippedInvContactDotSuspension: number; + customSlidingRotationalSpeed: number; dampingCompression: number; dampingRelaxation: number; - frictionSlip: number; - steering: number; - rotation: number; deltaRotation: number; - rollInfluence: number; - maxSuspensionForce: number; + directionLocal: Vec3; + directionWorld: Vec3; engineForce: number; - brake: number; - isFrontWheel: boolean; - clippedInvContactDotSuspension: number; - suspensionRelativeVelocity: number; - suspensionForce: number; - skidInfo: number; - suspensionLength: number; - sideImpulse: number; forwardImpulse: number; - raycastResult: RaycastResult; - worldTransform: Transform; + frictionSlip: number; + isFrontWheel: boolean; isInContact: boolean; + maxSuspensionForce: number; + maxSuspensionTravel: number; + radius: number; + raycastResult: RaycastResult; + rollInfluence: number; + rotation: number; + sideImpulse: number; + skidInfo: number; + sliding: boolean; + steering: number; + suspensionForce: number; + suspensionLength: number; + suspensionMaxLength: number; + suspensionRelativeVelocity: number; + suspensionStiffness: number; + suspensionRestLength: number; + useCustomSlidingRotationalSpeed: boolean; + worldTransform: Transform; constructor(options?: IWheelInfoOptions); } + export interface IRaycastVehicleOptions { + + chassisBody?: Body; + indexRightAxis?: number; + indexLeftAxis?: number; + indexUpAxis?: number; + + } + export class RaycastVehicle { chassisBody: Body; @@ -618,6 +752,7 @@ declare module CANNON { getVehicleAxisWorld(axisIndex: number, result: Vec3): Vec3; updateVehicle(timeStep: number): void; updateSuspension(deltaTime: number): void; + updateWheelTransform(wheelIndex: number): void; removeFromWorld(world: World): void; getWheelTransformWorld(wheelIndex: number): Transform; @@ -708,20 +843,15 @@ declare module CANNON { export class Box extends Shape { - static calculateIntertia(halfExtents: Vec3, mass: number, target: Vec3): void; + static calculateInertia(halfExtents: Vec3, mass: number, target: Vec3): void; - boundingSphereRadius: number; - collisionResponse: boolean; halfExtents: Vec3; convexPolyhedronRepresentation: ConvexPolyhedron; constructor(halfExtents: Vec3); updateConvexPolyhedronRepresentation(): void; - calculateLocalInertia(mass: number, target?: Vec3): Vec3; getSideNormals(sixTargetVectors: boolean, quat?: Quaternion): Vec3[]; - updateBoundingSphereRadius(): number; - volume(): number; forEachWorldCorner(pos: Vec3, quat: Quaternion, callback: Function): void; } @@ -730,6 +860,7 @@ declare module CANNON { static computeNormal(va: Vec3, vb: Vec3, vc: Vec3, target: Vec3): void; static project(hull: ConvexPolyhedron, axis: Vec3, pos: Vec3, quat: Quaternion, result: number[]): void; + static getFaceNormal(va: Vec3, vb: Vec3, vc: Vec3, target: Vec3): void; vertices: Vec3[]; worldVertices: Vec3[]; @@ -737,6 +868,7 @@ declare module CANNON { faces: number[]; faceNormals: Vec3[]; uniqueEdges: Vec3[]; + uniqueAxes: Vec3[]; constructor(points?: Vec3[], faces?: number[]); @@ -744,7 +876,7 @@ declare module CANNON { computeNormals(): void; getFaceNormal(i: number, target: Vec3): Vec3; clipAgainstHull(posA: Vec3, quatA: Quaternion, hullB: Vec3, quatB: Quaternion, separatingNormal: Vec3, minDist: number, maxDist: number, result: any[]): void; - findSaparatingAxis(hullB: ConvexPolyhedron, posA: Vec3, quatA: Quaternion, posB: Vec3, quatB: Quaternion, target: Vec3, faceListA: any[], faceListB: any[]): boolean; + findSeparatingAxis(hullB: ConvexPolyhedron, posA: Vec3, quatA: Quaternion, posB: Vec3, quatB: Quaternion, target: Vec3, faceListA: any[], faceListB: any[]): boolean; testSepAxis(axis: Vec3, hullB: ConvexPolyhedron, posA: Vec3, quatA: Quaternion, posB: Vec3, quatB: Quaternion): number; getPlaneConstantOfFace(face_i: number): number; clipFaceAgainstHull(separatingNormal: Vec3, posA: Vec3, quatA: Quaternion, worldVertsB1: Vec3[], minDist: number, maxDist: number, result: any[]): void; @@ -759,13 +891,13 @@ declare module CANNON { } - export class Cylinder extends Shape { + export class Cylinder extends ConvexPolyhedron { constructor(radiusTop: number, radiusBottom: number, height: number, numSegments: number); } - export interface IHightfield { + export interface IHightfieldOptions { minValue?: number; maxValue?: number; @@ -784,7 +916,7 @@ declare module CANNON { pillarOffset: Vec3; type: number; - constructor(data: number[], options?: IHightfield); + constructor(data: number[], options?: IHightfieldOptions); update(): void; updateMinValue(): void; @@ -826,13 +958,14 @@ declare module CANNON { } + id: number; type: number; boundingSphereRadius: number; collisionResponse: boolean; updateBoundingSphereRadius(): number; volume(): number; - calculateLocalInertia(mass: number, target: Vec3): Vec3; + calculateLocalInertia(mass: number, target?: Vec3): Vec3; } @@ -855,7 +988,7 @@ declare module CANNON { } export class Solver { - iterations: number; + equations: Equation[]; solve(dy: number, world: World): number; @@ -915,7 +1048,7 @@ declare module CANNON { export class Vec3Pool extends Pool { - type: any; + static defaults(options: Object, defaults: Object): Object; constructObject(): Vec3; @@ -924,8 +1057,66 @@ declare module CANNON { export class NarrowPhase { contactPointPool: Pool[]; + enableFrictionReduction: boolean; v3pool: Vec3Pool; + convexHeightfield(convexShape: Shape, hfShape: Heightfield, convexPos: Vec3, hfPos: Vec3, convexQuat: Quaternion, hfQuat: Quaternion, convexBody: Body, hfBody: Body): void; + convexConvex(si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + convexParticle(result: ContactEquation[], si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + convexTrimesh( result: ContactEquation[], si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + createContactEquation(bi: Body, bj: Body, si: Shape, sj: Shape, rsi: Shape, rsj: Shape): ContactEquation; + getContacts(p1: Body[], p2: Body[], world: World, result: ContactEquation[], oldcontacts: ContactEquation[]): void; + particlePlane( result: ContactEquation[], si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + particleSphere(result: ContactEquation[], si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + planeBox(result: ContactEquation[], si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + planeConvex(si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + planeTrimesh(si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + sphereBox(si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + sphereConvex(si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + sphereHeightfield(sphereShape: Shape, hfShape: Heightfield, spherePos: Vec3, hfPos: Vec3, sphereQuat: Quaternion, hfQuat: Quaternion, sphereBody: Body, hfBody: Body): void; + spherePlane( si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + sphereSphere(si: Shape, sj: Shape, xi: Vec3, xj: Vec3, qi: Quaternion, qj: Quaternion, bi: Body, bj: Body): void; + sphereTrimesh(sphereShape: Shape, trimeshShape: Shape, spherePos: Vec3, trimeshPos: Vec3, sphereQuat: Quaternion, trimeshQuat: Quaternion, sphereBody: Body, trimeshBody: Body): void; + + } + + export interface IOctreeOptions { + + root: Octree; + aabb: AABB; + + } + + export class OctreeNode { + + aabb: AABB; + children: Octree[]; + data: number[]; + root: OctreeNode; + + } + + export class Octree extends OctreeNode { + + maxDepth: number; + + constructor(aabb: AABB, options: IOctreeOptions); + + aabbQuery(aabb: AABB, result: Object[]): Object[]; + insert(aabb: AABB, elementData: Object): boolean; + rayQuery(ray: Ray, treeTransform: Transform, result: Object[]): Object[]; + removeEmptyNodes(): void; + subdivide(): void; + + } + + export interface IWorld { + + collisisonFilterMask?: number; + collisionFilterGroup?: number; + skipBackfaces?: boolean; + checkCollisionResponse?: boolean; + } export class World extends EventTarget { @@ -949,7 +1140,7 @@ declare module CANNON { collisionMatrix: ArrayCollisionMatrix; collisionMatrixPrevious: ArrayCollisionMatrix; materials: Material[]; - contactmaterials: ContactMaterial[]; + contactMaterials: ContactMaterial[]; contactMaterialTable: TupleDictionary; defaultMaterial: Material; defaultContactMaterial: ContactMaterial; @@ -965,16 +1156,23 @@ declare module CANNON { addBodyEvent: IBodyEvent; removeBodyEvent: IBodyEvent; - getContactMaterial(m1: Material, m2: Material): ContactMaterial; - numObjects(): number; - collisionMatrixTick(): void; addBody(body: Body): void; addConstraint(c: Constraint): void; - removeConstraint(c: Constraint): void; + addContactMaterial(cmat: ContactMaterial): void; + addEventListener(type: string, listener: Function): EventTarget; + addMaterial(m: Material): void; + clearForces(): void; + collisionMatrixTick(): void; + getContactMaterial(m1: Material, m2: Material): ContactMaterial; + numObjects(): number; + raycastAll(from: Vec3, to: Vec3, options: IWorld, callback: Function): boolean; + raycastAny(from: Vec3, to: Vec3, options: IWorld, result: RaycastResult): boolean; + raycastClosest(from: Vec3, to: Vec3, options: IWorld, result: RaycastResult): boolean; rayTest(from: Vec3, to: Vec3, result: RaycastResult): void; remove(body: Body): void; - addMaterial(m: Material): void; - addContactMaterial(cmat: ContactMaterial): void; + removeBody(body: Body): void; + removeConstraint(c: Constraint): void; + removeEventListener(type: string, listener: Function): EventTarget; step(dy: number, timeSinceLastCalled?: number, maxSubSteps?: number): void; } @@ -991,6 +1189,15 @@ declare module CANNON { } + export class Demo { + + constructor( options: Object ); + + addScene( title: string, initfunc: Function ): void; + restartCurrentScene(): void; + + } + } declare module "cannon" { diff --git a/cannon/tslint.json b/cannon/tslint.json deleted file mode 100644 index 2221e40e4a..0000000000 --- a/cannon/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "../tslint.json" } \ No newline at end of file