import { Baby } from './baby'; import { Tween } from '../middle/tween'; import { BabyEngine } from '../middle/babyengine'; import { Vector3 } from 'babylonjs'; /** superclass for BabyShape, BabyCamera and BabyButton */ export declare class BabyThing { model: string; uuid: number; baby: Baby; babyEngine: BabyEngine; lastTween: Tween; collideCallback: Function; clickCallback: Function; onPressDown: Function; constructor(model: string, babyEngine: BabyEngine); animatedGif(resultion?: number): BabyThing; /** Returns a promise that resolves when the LAST issued tween is completed. Use it as `await thing.move(...).done()` */ done(): Promise; /** Returns a promise that resolves when no tweens remain active. Use it as `await thing.isIdle()` */ isIdle(): Promise; } export declare class BabyShape extends BabyThing { constructor(model: string, babyEngine: BabyEngine); /** a callback when an ACTIVE shape collides with an ACTIVE or PASSIVE shape * note: if two ACTIVE shapes collide, they BOTH get a callback notification * eg: myBall.onCollide((other)=>{ // other is a BabyMesh object * if(other == hisBall){ doSomething() } * }) */ onCollide(callback: Function): BabyShape; /** a callback when the mouse clicks this shape. * eg: myBall.onClick(()=>console.log("I was clicked")) */ onClick(callback: Function): BabyShape; addAxes(): BabyShape; /** dispose of this shape or camera. */ dispose(): BabyShape; /** turn collisions on or off. 'active' will turn on gravity and mass. */ collide(collider?: 'ghost' | 'solid' | 'active'): BabyShape; /** Move an entity */ move(direction: 'forward' | 'backward' | 'left' | 'right' | 'up' | 'down', distance: number, duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): BabyShape; /** MoveAndTurn - moves in an arc (the turn affects the move) */ moveAndTurn(moveDirection: 'forward' | 'backward' | 'left' | 'right' | 'up' | 'down', distance: number, turnTowards: 'forward' | 'backward' | 'left' | 'right' | 'tiltLeft' | 'tiltRight', angle: number, duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): BabyShape; /** MoveToward- moves towards another shape. Often getDistanceTo(other) is useful. */ moveToward(other: BabyShape, distance: number, duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): BabyShape; moveToZero(duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): BabyShape; /** Turn an entity (1 is a full turn) * * @remarks * You get different results from the two cases below, because in the second case * the box waits to finish the first turn before starting the second. Even if you * do the turns in zero-time, you cannot be sure which will be performed first unless * you wait. Consider using the 'legacy' function `setRotation()`. * * * ``` * box.turn('forward',.25) * box.turn('left',.25) * ``` * and * ``` * await box.turn('forward',.25).done() * box.turn('left',.25) * ``` */ turn(towards: 'forward' | 'backward' | 'left' | 'right' | 'tiltLeft' | 'tiltRight', angle: number, duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): this; turnToSame(other: BabyShape, duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): this; turnToZero(duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): this; /** * Size or resize an entity (same as Babylon 'scale' for simple shapes) */ size(size: number | number[], duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): BabyShape; /** * Sets diffuse color (the essential color under white light). For controls * on ambient, emmisive, or specular color, use 'setColor()' * @param {diffuseColor} string is one of 140 HTML color names eg: 'mediumvioletred' */ color(diffuseColor: string, duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): BabyShape; /** Sets opacity between 0 (transparent) and 1 (solid) */ opacity(opacity: number, duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): BabyShape; /** Creates a skeleton frame on a shape */ addSkeleton(): BabyShape; /** Adds to a shape that has a skeleton */ attachTo(other: BabyShape): BabyShape; /** Kill any in-progress moves (usually because of a collision). Turns are not affected. 'Await' will fire if anyone is waiting. */ break(): BabyShape; /** Set positon of this shape immediately. This is the Babylon way of moving shapes. It is * particularly useful for setting an initial position */ setPosition(leftRight: number, upDown: number, frontBack: number): BabyShape; /** modify positon of this shape immediately. This is the Babylon way of moving shapes. */ addToPosition(leftRight: number, upDown: number, frontBack: number): BabyShape; /** set direction of this shape immediately. This is the Babylon way of rotating shapes. * The absolute values of the numbers aren't important. (0,1,0) is the same as (0,100,0). * Rotations are performed around the x, y, z axis in order. * */ setRotation(leftRight: number, upDown: number, frontBack: number): this; /** modify rotation of this shape immediately. This is the Babylon way of rotating shapes. A quarter-rotation is .25, as usual */ addToRotation(leftRight: number, upDown: number, frontBack: number): this; /** drop a pen, and start creating a 3d line in space */ penDown(radius?: number): this; /** raise the pen, stop drawing a 3d line */ penUp(): this; /** erase a line created with `penDown` and `penUp` */ lineErase(): this; /** sets a texture with HTML Canvas commands, for example: * let params = { 'text': '5'} * numberCube.setTexture(params, () => { * ctx.fillStyle = 'yellow'; * ctx.beginPath(); * ctx.rect(0, 0, 1024, 1024); // preset to 1024 * ctx.fill(); * * ctx.beginPath(); * ctx.moveTo(200, 200) * ctx.fillStyle = 'blue'; * ctx.font = "512px Arial"; * ctx.fillText(params['text'], 300, 600) * }) */ setTexture(params: object, ctxFunction: Function): this; /** position of this thing at this instance */ getPosition(): Vector3; /** direction of this thing at this instance */ getRotation(): Vector3; /** scale of this thing at this instance */ getSize(): Vector3; /** distance to another shape (center-to-center, so watch out if you have resized one of them) */ getDistanceTo(otherShape: BabyShape): number; /** get the HTML context for drawing on this shape * eg: let box = app.cube() * let ctx = box.getContext() * ctx.fillStyle = 'red' * ctx.beginPath() * ctx.rect(0, 0, 100,100) * ctx.fill() */ getContext(): CanvasRenderingContext2D; } export declare class Vt52Thing extends BabyShape { constructor(model: string, babyEngine: BabyEngine); /** A VT52 is like an old-fashioned text terminal. Embed \n in your string for a newline * * @remarks * vt52.print() is an async, so you can use `await vt52.print('done')`. The * promise is resolved when the *LAST* character in the buffer is printed, so * you can print multiple statements and only `await` the last one. * * `Await vt.print()` only waits for the local machine, but all players should take the same time. * */ print(text: string, color?: string): Promise; /** A simple wait-for-input. Make sure you remember the `async` before `vt52.input() * async myFunction(){ * let userName = await vt52.input("What's your name? ") * vt52.print("Hello " + userName) * } * * You can't use this for multi-player because it doesn't tell you WHO typed. */ input(prompt?: string): Promise; } /** A 2D graph class for showing math */ export declare class BabyGraph extends BabyShape { scaleX: number; scaleY: number; constructor(model: string, babyEngine: BabyEngine); /** draw a grid from -x to x, from -y to y (defaulting to the graph size). */ drawGrid(x?: number, y?: number): BabyGraph; /** draw a line through a series of points declared as [x,y] * eg: graph.line([2,1],[2,2],[3,3]) */ line(markerSymbol: 'none' | 'arrow' | 'arrowdot' | 'dot', start: [number, number], ...restofPoints: [number, number][]): BabyGraph; /** draw a circle of radius r at point [x,y] * eg: graph.circle([2,1],5) */ circle(point: [number, number], radius: number): BabyGraph; /** draw a rectangle defined by bottom-left and top-right points * eg: graph.rectangle([-3,-3],[2,1]) */ rectangle(point1: [number, number], point2: [number, number]): BabyGraph; textAt(text: string, x: number, y: number, offsetX?: number, offsetY?: number): this; } export declare class BabyCamera extends BabyThing { constructor(model: string, babyEngine: BabyEngine); /** Move an entity */ move(direction: 'forward' | 'backward' | 'left' | 'right' | 'up' | 'down', distance: number, duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): BabyCamera; /** MoveToward- moves towards another shape. Often getDistanceTo(other) is useful. */ moveToward(other: BabyShape, distance: number, duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): BabyCamera; moveToZero(duration?: number, animate?: '1-Begin And End Normally' | '2-Begin Slow, End Fast' | '3-Begin Fast, End Slow' | '4-Begin And End Fast' | '5-Begin And End Slow'): BabyCamera; /** set camera mode to Orthographic (ie: not Perspective) */ setOrthographic(orthoSize?: number): this; /** set camera mode to Orthographic (ie: not Perspective) */ setActive(player?: number): this; /** gives players control of the camera) */ attachControls(): this; }